On Tue, 27 Aug 2002, Sean O'Rourke wrote:
> On Tue, 27 Aug 2002, Luke Palmer wrote:
> > On 27 Aug 2002, Piers Cawley wrote:
> > > Damian Conway <[EMAIL PROTECTED]> writes:
> > > > Debbie Pickett asked:
> > > > > (Offtopic: can I say:
> > > > > $c = -> $xyz { mumble }
> > > >
> > > > Yes. Though you need a semicolon at the end unless its the last
> > > > statement in a block.
> > >
> > > Um... when did that rule come in? I thought a statement ending closing
> > > brace merely had to match C<< rx/ \} [ ; | \s* \n] / >>.
> >
> > Nope. It's C< rx/^^ \s* \} \s* $$/ > (or the usual C< }; >)
>
> I hope this is wrong, because if not, it breaks this:
>
> if 1 { do something }
> foo $x;
>
> in weird ways. Namely, it gets parsed as:
>
> if(1, sub { do something }, foo($x));
>
> which comes out as "wrong number of arguments to `if'", which is just
> strange.
No, it's right. But it doesn't break that. In the grammar, C-like
languages include (something like):
statement: expression ';'
statement: if expression block
So an if _statement_ terminates itself. The } on a line of its own is a
special exception for closing braces that would also need a semincolon,
as in C<eval> (that is, C<try>), et cetera.
Luke