Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does it need parentheses for some built in functions but not for others? #111

Closed
anonyno opened this issue Oct 27, 2020 · 2 comments
Closed
Labels

Comments

@anonyno
Copy link

anonyno commented Oct 27, 2020

maybe i just don't understand Perl but why is print; okay but not die;. i need to use die(); for it not to complain.

Also print 'example' is okay even though "All subroutines must use parentheses".

@xsawyerx xsawyerx added the bug label Jan 30, 2021
@xsawyerx
Copy link
Owner

maybe i just don't understand Perl but why is print; okay but not die;. i need to use die(); for it not to complain.

This is indeed a bug. I've marked this ticket as such.

Also print 'example' is okay even though "All subroutines must use parentheses".

print (and die) are not "subroutines," they are "keywords." Keywords are the reserved barewords provided by the language, also referred to as "builtins" or "builtin functions." They do not need parenthesis by default because we are aware of their parsing rules.

User-created functions ("subroutines") require parenthesis so we can adequately figure out how to lex and parse them. Subroutine prototypes allow the user to give the perl lexer additional parsing rules so it can avoid parenthesis but that makes it very difficult to statically parse because you need to go into compilation mode to introduce these new prototypes and understand them. This is why Guacamole doesn't support subroutine prototypes and requires all subroutines (user-provided functions) to include parenthesis.

xsawyerx added a commit that referenced this issue May 30, 2022
@xsawyerx
Copy link
Owner

die is now supported.

xsawyerx added a commit that referenced this issue Jun 20, 2022
    * GH #23: (VERY) Preliminary support for extending the grammar.
    * GH #111: Support "die".
    * GH #112: Support "readline STDIN" or "readline(STDIN)".
    * GH #113: Support "$#_" (but not "$# _").
    * GH #114: Support all forms of binmode() (Val @valcomm).
    * GH #115: Support all forms of for() loop (Val @valcomm).
    * RT #132920: Fix confusion of quote-like operators by comments.
    * Support "_" in file operations ("-x _", etc.).
    * Support "$foo->$bar" and "$foo->$_".
    * Support 'eval "..."' or 'eval $foo'.
    * Improve wording on top-level anonymous hashes.
    * When failing without an exception, we throw an exception with
      more information (e.g., "print _").
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants