develooper Front page | perl.perl5.porters | Postings from November 2021

Re: Pre-RFC: Phaser Expressions

Thread Previous | Thread Next
David Nicol
November 20, 2021 01:49
Re: Pre-RFC: Phaser Expressions
Message ID:

On Thu, Nov 18, 2021 at 2:16 AM Branislav ZahradnĂ­k <>

>> my $initialized = 1 at INIT;
>> Hm, we can read such expression as "default value of variable available
> since phase X". Using my previous proposal:
> my $foo := :default => BEGIN { 1 };
> my $bar := :default => INIT { 1 };

I don't understand why you're limiting the proposed new grammar to variable

The keywords  "my" and "our" are syntactic sugar for two separate

   1. declare a lexical variable, that might be an alias for a package
   2. when used as an L-value, initialize said variable when execution
   reaches the code

For ease, the two can be combined.

If you don't want them combined, don't combine them.

      my $foo; BEGIN {$foo = 'set at compile time'}

What's the problem?

My counter-proposal

   1. solves the only problem I see, which is that you don't like the look
   of curly braces and want to reduce their quantity: "my $foo = 27 at BEGIN;"
   has no curlies and is pretty concise and doesn't introduce any new syntax,
   just a new keyword "at" of a class of keywords we already have.
   2. opens the door for more flexible postfix flow control modifiers,
   like  { $bar = 3 if $foo if $baz } instead of { $baz and $foo and $bar = 3
   }, which would mean the same thing exactly. Unless I missed the change,
   postfix flow control modifiers currently don't stack, possibly due to the
   confusion over which level would own the topic, to which I would say "the
   innermost, obviously."

"Lay off that whiskey, and let that cocaine be!" -- Johnny Cash

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About