develooper Front page | perl.perl5.porters | Postings from July 2016

[perl #36333] sort CONSTANT exhibits weird behavior

Thread Next
Father Chrysostomos via RT
July 8, 2016 04:30
[perl #36333] sort CONSTANT exhibits weird behavior
Message ID:
On Thu Jul 07 17:58:18 2016, wrote:
> It's being interpreted as a bareword for some reason?

Oh, what fun!  This is a very old bug.  And it occurs because of the way that the parser gets to decide whether the first token after ‘sort’ is a comparison sub or part of the list to sort.

The lexer (toke.c) assumes that any word immediately following ‘sort’ is a comparison sub, which gets emitted as a WORD token, just like a bareword.

It is the parser (perly.y) that distinguishes between these two:

    sort foo bar
    sort foo,bar

So the lexer does not actually know at the time whether the word will be a comparator or not.  That makes it hard to fix.

(All of this is from memory.  I may be getting some of it wrong.)

use constant{Just=>another=>Perl=>hacker=>};$\=",\n";
print join" ",map eval"sort $_,$_",qw!     Just Perl!


Father Chrysostomos

via perlbug:  queue: perl5 status: open

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