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

Re: RFC: Multiple-alias syntax for for

Thread Previous | Thread Next
From:
Paul "LeoNerd" Evans
Date:
June 15, 2021 11:42
Subject:
Re: RFC: Multiple-alias syntax for for
Message ID:
20210615124150.0d9c9c81@shy.leonerd.org.uk
On Tue, 15 Jun 2021 13:18:29 +0200
Branislav ZahradnĂ­k <happy.barney@gmail.com> wrote:

> Allowing new syntax only with "use v5.xx" guard prevents situation
> when your code
> starts to break after OS upgrade (downgrade) on syntax error.
> 
> Hiding new syntax behind new guard says to managers (if they are
> listen to they programmers)
> hey, perl is not dead, there is new version, we should upgrade ...
> (ideally without refactoring)

We didn't do that with // or ->@*


$ perl5.8.9 -e 'print undef // 123'
Warning: Use of "undef" without parentheses is ambiguous at -e line 1.
Number found where operator expected at -e line 1, near "// 123"
        (Missing operator before  123?)
syntax error at -e line 1, near "// 123"
Execution of -e aborted due to compilation errors.

$ perl5.10.1 -e 'print undef // 123'
123


$ perl5.22.2 -E 'say [1,2,3]->@*'
Array found where operator expected at -e line 1, near "->@*"
        (Missing operator before @*?)
syntax error at -e line 1, near "->@*
"
Execution of -e aborted due to compilation errors.

$ perl5.24.4 -E 'say [1,2,3]->@*'
123



-- 
Paul "LeoNerd" Evans

leonerd@leonerd.org.uk      |  https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/  |  https://www.tindie.com/stores/leonerd/

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