Yes, good point, I was thinking of e.g. if and for, but I didn't list goto but did list return - now that I think about it some more, I probably shouldn't have listed the latter because it can't really be approximated by a sub (that's how I personally generally differentiate between "functions" and "operators" in Perl, but this isn't perfect and a pretty big grey area).
| [reply] [d/l] [select] |
In my book
- (named) function something of the form Name(Args) usable as EXPR, that means returning a value at runtime. Parens can be omitted if precedence is clear. Arguments - if any - must follow to the right, either as one UNARY value or as comma separated LIST.
- builtin : a named function in the language core. The name is a reserved keyword. Some may have special parsing rules for arguments and special context, such that they can't be replicated with sub (PROTOTYPE) { BLOCK }
- operator symbols acting like functions by returning values but with "surrounding" (not necessarily following) arguments, special parsing and precedence like 2 * 3 . See perlop
and overload
- named operators like xor have an alphanumeric IDENTIFIER as "symbol". NB: some builtin functions are sometimes documented as "operators" (it's just a huge subgroup with a more standard syntax)
- statement keywords anything requiring void context. I.e. can't be used in an expression (without do ). It usually follows a semicolon and is used for side-effects . Most at compile time like like use
- Some of them are documented as "function-like keywords" because they parse like functions like my but are primarily used for declaration (a compile time side effect)
Please expand/correct me. ..
EDIT
N.B. some keywords fall into multiple categories, depending on usage.
sub name { Block } is a statement declaring a subroutine at compile time.
$code = sub { Block }; is a builtin function returning a coderef at runtime.
| [reply] [d/l] [select] |
| [reply] |