Closed p5pRT closed 16 years ago
According to apocalypse 4\, "given" and "when" do not rquire parens around their arguments. According to perly.y in blead\, however\, they do\, e.g. "given ($foo)" works\, but "given $foo" does not.
On Tue\, Dec 27\, 2005 at 11:15:12AM -0800\, Sean O'Rourke wrote:
According to apocalypse 4\, "given" and "when" do not rquire parens around their arguments. According to perly.y in blead\, however\, they do\, e.g. "given ($foo)" works\, but "given $foo" does not.
See:
http://groups.google.com/groups?threadm=20051209131351.GA1365@rpc142.cs.man.ac.uk
The RT System itself - Status changed from 'new' to 'open'
"Yitzchak Scott-Thoennes via RT" \perlbug\-followup@​perl\.org writes:
See:
http://groups.google.com/groups?threadm=20051209131351.GA1365@rpc142.cs.man.ac.uk
Thanks\, and (perhaps) disregard my previous message. It might be worth adding a test that highlights *why* the parens are required in Perl 5. Apparently none of the current tests do so.
/s
For what it's worth\, this patch appears to fix it and passes all the current tests.
/s
On Tue\, Dec 27\, 2005 at 11:46:52AM -0800\, Sean O'Rourke wrote:
"Yitzchak Scott-Thoennes via RT" \perlbug\-followup@​perl\.org writes:
See:
http://groups.google.com/groups?threadm=20051209131351.GA1365@rpc142.cs.man.ac.uk
Thanks\, and (perhaps) disregard my previous message. It might be worth adding a test that highlights *why* the parens are required in Perl 5. Apparently none of the current tests do so.
Any differences from perl6 should be documented\, if they are not already\, so bug-minders\, please don't close this yet.
According to apocalypse 4\, "given" and "when" do not rquire parens around their arguments. According to perly.y in blead\, however\, they do\, e.g. "given ($foo)" works\, but "given $foo" does not.
It's worth noting that\, in Perl 6\, "if" and "while" do not require parens around their arguments either.
The fundamental problem is this: in Perl 6\, whitespace is forbidden in certain places where it is permitted in Perl 5\, which makes it possible to disambiguate between C\<if %foo { ... }> and C\<if %foo{ ... } { ... }>\, for example.
If the parentheses are made optional in Perl 5 -- or at least if this is done in the naive way\, as in Sean's patch -- an expression such as
given $foo { print "Oh look! It's foo.\n" }
would be parsed as
given ($foo{ print "Oh look! It's foo.\n" })
and then throw a syntax error because the expression is not followed by a block. (That's what happens when your parse is determined by just one token of lookahead!)
Of course this difficulty is not necessarily insurmountable\, and
one can imagine ways that it might be overcome. But I think this
is misguided thinking: if we are to make the parentheses optional
here\, we should also do so for C\
Robin
PS. I agree that differences from Perl 6 should be documented somewhere. I'll send a patch.
p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#38050 (status was 'resolved')
Searchable as RT38050$