I can't seem to be able to reply to other replies (too much nesting probably). Perhaps I'll try the chatterbox or a separate question.
I was trying to understand if the Perl compiler parses "f ($_)" in "map f ($_), @numbers" as a lambda. If it's not a block, but an expression, it must be either an arithmetic expression, a lambda expression etc. My question was from a syntactic/compiler point of view.
And as to eager evaluation, obviously this is a counterexample, since map f($_) @nums doesn't immediately, eagerly evaluate f on the current $_, but instead passed a lambda to map()
Your use of syntax leaves me with the impression that before Perl you only knew Haskell, or some other, lazy / currying functional language.
The major difference between Perl and these others is that Perl is eager, so any unadorned mention of a function will simply call it. Unless you use built-in functions or fancy syntax tricks, all function parameters are passed in parentheses.
Creating/returning new functions is quite possible in Perl, but the usual approach is more eager in the sense of passing around values instead of passing around functions that, at some time in the future will be called to produce the final output of the program.
A syntactic construct consisting of a sequence of Perl stat
that is delimited by braces. The "if" and "while" statemen
defined in terms of BLOCKs, for instance. Sometimes we als
"block" to mean a lexical scope; that is, a sequence of sta
that act like a "BLOCK", such as within an eval or a file,
though the statements arenít delimited by braces.
Anything you can legally say in a spot where a "value" is
required. Typically composed of literals, variables, opera
functions, and "subroutine" calls, not necessarily in that