in reply to order in map

This is indeed ugly as are many of the fixes (though I do like suaveant's). I think in perl6 this can be disambiguated as

my %hash = map { "stuff_$_" => $_ } <== qw(asdf qwert zxcv);

... as per Synopsis 3. There may be some other new way to do this (?) in perl6 as well.

Update: It seems they are still wrestling with this in perl6 (see section on map), although the piping I use above is one way to disambiguate and is not available in perl5.

Replies are listed 'Best First'.
Re^2: order in map
by Anonymous Monk on May 04, 2005 at 15:46 UTC
    Eh, I don't think the <== will help. It's too far away. The problem is that when encountering the {, perl has to decide whether what's following is a block or a hashref. And to decide that, it can only look a limited amount of tokens ahead. (2 tokens, I think). So, when it sees the { followed by a string, followed by a comma (or fat arrow), it thinks it's a hashref, as hashes are often declared as string, comma, string, comma, etc. But if it sees a unary plus, or a string followed by a dot - basically, anything that isn't a string followed by a comma, it guesses 'block'.

    Most likely, perl6 will still be a limited look-ahead parser, and not for instance something generated by Parse::RecDescent. Limited look-ahead parsers are much faster than unlimited look-ahead parsers, due to the fact they can do table lookups, and don't have to backtrack.

      Interesting. I hope *something* is done about this but it's a bit late for that ;->