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

Re: Pre-RFC: Phaser Expressions

Thread Previous | Thread Next
November 17, 2021 19:59
Re: Pre-RFC: Phaser Expressions
Message ID:
> Quick, what happens here?
> use strict;
> my $oo;
> $foo = do { BEGIN { 1 } };
> print $foo,$/;
> BEGIN, CHECK, INIT, END blocks etc. are not subroutines for a very good
> reason: they are not arbitrarily callable and don't but establish some
> special kind of flow control for code wrt execution time, nothing more.
You got it little bit wrong. I'm not talking about treating phasers as a
value expressions
I'm talking about new grammar rule, shortly speaking:

statement: variable-list '=' BEGIN block;


statement: BEGIN variable-list = expression

in both cases you (or someone who will implement this) has to some kind of
AST transformation
(I know, perly doesn't have AST layer) so expressions with different then
BEGIN will make sense:

INIT my $initialized = 1;
my $initialized = INIT {  1  };

first variant will be misleading (especially for newbies - yes, I still
believe that there is a willingness to attract some)

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