in reply to Re^18: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT)
in thread printing unitialized value of the 'do BLOCK'

> Your usage of the terms clearly differs from the documentation's.

Depending on the definition you take

I'd say according to perlglossary it must be parsable without surrounding do {}

  • expression

    Anything you can legally say in a spot where a value is required. Typically composed of literals, variables, operators, functions, and subroutine calls, not necessarily in that order.

  • But according to WP expression, the defining characteristic is returning a value

    An expression in a programming language is a combination of one or more constants, variables, operators, and functions that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value.

    I'd compromise on "statement which can be used like an expression to produce values".

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

    • Comment on Re^19: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT)
    • Download Code

    Replies are listed 'Best First'.
    Re^20: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT)
    by ikegami (Patriarch) on Dec 28, 2019 at 17:33 UTC

      Depending on the definition you take

      Yes. I clearly said it doesn't make sense for your definition.

      I'd compromise on "statement which can be used like an expression to produce values".

      I presume you are saying this is what an if statement is. It's not. You can't count on it returning anything according to the documentation, and a provided example demonstrated this.

        > You can't count on it returning anything according to the documentation, and a provided example demonstrated this.

        The only examples I remember seeing demonstrate syntax errors, when if isn't used in a statement spot.

        Do you have an example where if doesn't return a value as last statement inside inside a do, eval or sub {BLOCK} or similar?

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

          It's all covered by my initial post. It explains that the documentation doesn't define what happens and that it could be implied that it's Undefined Behaviour, it explains what usually happens, and it explains that you can't always count on it happening (in the form of a link to a reply that provides an example where it doesn't happen).