develooper Front page | perl.perl5.porters | Postings from September 2018

[perl #133470] Sub + ok, but * fails

From:
Tony Cook via RT
Date:
September 6, 2018 03:16
Subject:
[perl #133470] Sub + ok, but * fails
Message ID:
rt-4.0.24-12831-1536203804-475.133470-15-0@perl.org
On Thu, 23 Aug 2018 23:18:26 -0700, grinnz@gmail.com wrote:
> On Thu, Aug 23, 2018 at 8:11 PM Philip R Brenan (via RT) <
> perlbug-followup@perl.org> wrote:
> 
> >
> > #!/usr/bin/perl
> > sub c {1};
> > my $d = c + (+1); # OK
> >    $d = c - (+1); # OK
> >    $d = c % (+1); # syntax error at subTimes.pl line 4, near "1)"
> >    $d = c * (+1); # syntax error at subTimes.pl line 5, near "1)"
> >
> >
> I believe this is just a parser quirk because it attempts to parse the
> tokens following 'c' as the first argument to the function, %( + 1 (then
> syntax error for unmatched closing parentheses) or *( + 1 (and same).
> Unfortunately whitespace doesn't disambiguate it since (despite nobody ever
> using it) you can optionally put whitespace between a sigil and variable
> name. You can unconfuse the parser by calling the function as c() or
> putting the other argument first.

Yeah, this isn't a bug, closing.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133470



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