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 17, 2021 19:59
Subject:
Re: Pre-RFC: Phaser Expressions
Message ID:
CAB=rbOkkUsUsRx_6ju-pDUWOa0XMqrM+FACdDegZPdWVbGsY7g@mail.gmail.com
> 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;

vs

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;
vs.
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


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