Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^5: My problems to understand the Perl documentation

by LanX (Sage)
on Aug 24, 2020 at 16:06 UTC ( #11121038=note: print w/replies, xml ) Need Help??


in reply to Re^4: My problems to understand the Perl documentation
in thread My problems to understand the Perl documentation

> most people would classify as keywords and operators instead of functions

For me any reserved word is a keyword, this includes functions.

I know what you mean but "keyword" doesn't describe it.

See also perlfunc#Perl-Functions-by-Category ... which is even more confusing.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re^5: My problems to understand the Perl documentation

Replies are listed 'Best First'.
Re^6: My problems to understand the Perl documentation
by haukex (Bishop) on Aug 24, 2020 at 19:08 UTC

    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).

      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.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      To make things more complicated...

      Took a look into

      CORE

      and there "built-in functions" and "keywords" are used as synonyms. :/

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121038]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2022-05-26 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (93 votes). Check out past polls.

    Notices?