A while ago I posted a conflict between a block containing a pair constructor, vs. a hash constructor:
map { $_ => $_ } @foo;
Larry suggested that to keep it from being collapsed, we somehow
augment toplevel AST:
map { $_ => $_; } @foo;
map { +($_ => $_) } @foo;
But here is a new idea: Since the parser knows that the bare block is
followed by no trailing comma, how about we using it as a disambiguating
device, and define that it never collapses?
map { $_ => $_ } @foo; # closure
map { $_ => $_ }, @foo; # hash
And maybe it can be extended over adverbial blocks, too:
@foo.map:{ $_ => $_ }; # closure
Also as control structure body, just for consistency's sake:
for @foo { $^x => $^y };
Is it a sane approach? I have just tentatively implemented it as r2305
if people would like to experiment with this proposal.
Thanks,
/Autrijus/
pgpGr0w8m9W9k.pgp
Description: PGP signature
