Mailing List Archive

Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables
Currently, each punctuation variable has an $ENGLISH_NAME alias available
for readability. But this has a couple problems: it's only available if you
"use English;" which does not provide a direct indication of the variables
it's related to in the code, and was a significant performance penalty in
older versions of Perl; these issues leading to not much use of the module
and thus the knowledge of their existence has not become widespread; so
average Perl programmers finding $CHILD_ERROR in Perl code are likely not
to know it's an alias for $? or that it's a built-in variable at all, thus
reducing its effective readability instead of increasing it.

Proposed by haarg in https://github.com/Perl/perl5/issues/18699 is to add
aliases like ${^CHILD_ERROR}, using the built-in variable form used for
other more recently added built-in variables.

This has a few advantages: it provides a readable indication of its purpose
like those provided by "use English"; it is clearly a built-in variable to
those who have come across that syntax, and clearly not a regular variable
to those who don't; and it doesn't require an opt-in such as "use English"
as this syntax is already available for Perl to add any new variable names.

The risks are primarily that it doesn't end up being useful and in the
process uses up a bunch of built-in variable names - but reusing the
existing English names for any other purpose strikes me as a poor idea
regardless. It also is likely to be considered uglier than English
variables, due to the extra punctuation required.

This may also be a tangential way to work toward addressing the problem of
rarely-used punctuation variables preventing the use of syntax for other
purposes, such as discussed in https://github.com/Perl/perl5/issues/18393.

-Dan
Re: Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables [ In reply to ]
2021-10-30 8:47 Dan Book <grinnz@gmail.com> wrote:

> Currently, each punctuation variable has an $ENGLISH_NAME alias available
> for readability. But this has a couple problems: it's only available if you
> "use English;" which does not provide a direct indication of the variables
> it's related to in the code, and was a significant performance penalty in
> older versions of Perl; these issues leading to not much use of the module
> and thus the knowledge of their existence has not become widespread; so
> average Perl programmers finding $CHILD_ERROR in Perl code are likely not
> to know it's an alias for $? or that it's a built-in variable at all, thus
> reducing its effective readability instead of increasing it.
>
>
One of the most common criticisms of Perl is its low readability.

Although this is partly a hype, I feel it's true that punctuation variables
aren't readable as they are.

Although ${^FOO} is a little peculiar, the word can be searched by
searching engines such as Google, Bing, and I realize it is a special
variable.

I agree with this proposal.
Re: Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables [ In reply to ]
Is there anyone who wants to move this proposal forward?

Personally I want to write the following for beginners who don't know the
details of Perl.

# Current
while (my $line = <>) {
if ($. == 1) {
next;
}
}

# Future
while (my $line = <>) {
if (${^INPUT_LINE_NUMBER} == 1) {
next;
}
}
Re: Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables [ In reply to ]
On Mon, 13 Dec 2021 08:37:17 +0900
Yuki Kimoto <kimoto.yuki@gmail.com> wrote:

> Is there anyone who wants to move this proposal forward?

I don't think I'd have time to actually implement it myself.

But I don't object to the idea, I think it sounds fine. I can point
someone along the way to where to try implementing it, if a volunteer
appears.

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables [ In reply to ]
2021-12-13 19:43 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:

> On Mon, 13 Dec 2021 08:37:17 +0900
> Yuki Kimoto <kimoto.yuki@gmail.com> wrote:
>
> > Is there anyone who wants to move this proposal forward?
>
> I don't think I'd have time to actually implement it myself.
>
> But I don't object to the idea, I think it sounds fine. I can point
> someone along the way to where to try implementing it, if a volunteer
> appears.
>
>
Thank you.

Is it possible to recruit volunteers if there is no strong opposition to
this proposal?

I have time to spare.
Re: Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables [ In reply to ]
This seems like a fine idea and nobody's objected to it yet.

Can you please write it up as a formal RFC on the usual process:

https://github.com/Perl/RFCs/

We have allocated the number 0014 for it.

Thanks,

--
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
Re: Pre-RFC: ${^ENGLISH_NAME} aliases for punctuation variables [ In reply to ]
2022-1-22 0:05 Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> wrote:

> This seems like a fine idea and nobody's objected to it yet.
>
> Can you please write it up as a formal RFC on the usual process:
>
> https://github.com/Perl/RFCs/
>
> We have allocated the number 0014 for it.
>
> Thanks,
>
>
I will start to write the RFC in a month.