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

Re: Pre-RFC: Phaser Expressions

Thread Previous | Thread Next
November 18, 2021 08:16
Re: Pre-RFC: Phaser Expressions
Message ID:
On Thu, 18 Nov 2021 at 05:32, David Nicol <> wrote:

> I don't like it.
> That said, if we must do this I'd like to see it postfix, like the other
> non-bracketing modifiers that happen and ends of expressions, which are if,
> while, unless, for, and possibly something else I missed. We would
> introduce a new postfix expression keyword, "at" or "during" or "atphase"
> or something like that, of the same class as postfix if and friends, and it
> would only be syntactically correct when followed by one of the "phasers."
> it would look like this:
> my $initialized = 1 at INIT;
> That's my two sunken rai stones.
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 };

Advantage: new grammar, new behaviour, not conflict with existing terms,
chains, or so (new grammar unambiguous as far as I'm aware of)
Disadvantage: new grammar

Details of phaser default value:
- evaluated in phase
- assigned to variable on first read
- destroyed after evaluation if already initialized

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