On Sun, Apr 24, 2005 at 04:39:04PM -0700, Larry Wall wrote:
> : Larry suggested that to keep it from being collapsed, we somehow
> : augment toplevel AST:
> :
> : map { $_ => $_; } @foo;
> : map { +($_ => $_) } @foo;
>
> Uh, I'm not sure what + would return for a Pair, but I'm pretty sure it's
> not a pair. A little P5ism sneaking in there? :-)
Aye, indeed. :-)
> : 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
>
> A block can be arbitrarily long. I worry about disambiguating it by
> something could come lines later. It's the /x problem all over again.
> Plus, I think many folks would rather think of the closure comma as
> optional rather than mandatorily missing. Besides, if they can't
> keep the {...} straight, they're not gonna keep the comma straight either.
Okay, I concur. r2319 now renders the trailing comma / adverbial colon
orthogonal to closure collapsing again; I have also implemented your
top-level-expression rule from an easlier thread. So to disambiguate,
one has to write this now:
map { $_ => $_; } @foo;
This works too:
map { ;$_ => $_ } @foo;
But () is still only a grouper, so this won't do:
map { ($_ => $_) } @foo;
Does this make sense?
Thanks,
/Autrijus/
pgppdAs3gEUYk.pgp
Description: PGP signature
