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

Re: Pre-RFC: Phaser Expressions

Thread Previous | Thread Next
From:
=?UTF-8?Q?Branislav_Zahradn=C3=ADk?=
Date:
November 18, 2021 08:16
Subject:
Re: Pre-RFC: Phaser Expressions
Message ID:
CAB=rbO=iq+mjPWCmLYOYVYDvWdPArSO4Ch2H83KStoo+N6kiLg@mail.gmail.com
On Thu, 18 Nov 2021 at 05:32, David Nicol <davidnicol@gmail.com> 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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About