No such thing as a small change | |
PerlMonks |
Re^16: printing unitialized value of the 'do BLOCK' (EXPRESSION vs TERM vs STATEMENT)by ikegami (Patriarch) |
on Dec 27, 2019 at 06:16 UTC ( [id://11110651]=note: print w/replies, xml ) | Need Help?? |
A file is a sequence of statements. A block is a sequence of statements in curlies. A statement can be a flow control statement (if, while, etc), a simple statement (an expression used for its side-effects), as well as other things. An expression defines the syntax of code required to evaluate to one or more values. For example, an if statement's condition must be an expression. No one used the word "term". It's a parser rule that usually encompasses variables, literals and sub-expressions in parens. Not a very useful word.
No. For example, 1+2 is not a term. An expression inside a statement is an expression (which contains terms).
No, it doesn't. "The only kind of simple statement is an expression evaluated for its side-effects" is equivalent to "an expression evaluated for its side-effects is a simple statement." In other words, expressions are also statements. For example, print("x") is an expression (so you can do if (print("x")) { ... }), but it can also be used as a statement.
Both "statement" and "expression" are names of parser rules. As parser rules, there are two differences between them: The syntax they allow, and where they can be used.
In Section
Seekers of Perl Wisdom
|
|