In a message dated Tue, 27 Aug 2002, Luke Palmer writes:
> 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.
It's a special exception *intended for* those cases. But you can use it
elsewhere, e.g.
my $addsub = {
return @_[0] + @_[1];
}
my $subsub = { return @_[0] - @_[1] };
I assume that comments are transformed into \s prior to other rules
taking effect (aside from transformation of quotelikes using # as the
delimiter). So I could put a comment at the end of the line containing
only the closing brace, and everything would still work.
Btw, putting on my stylist hat, I think the fluent Perl 6 programmer would
use C<sub> or C<< -> >> in the code above in order to clarify what's going
on there, don't you? Or am I thinking like a Perl 5 programmer?
It would certainly help to make clear the difference between:
my $foo = { bar => "baz" }; # Make hash
and:
my $foo = sub { bar => "baz" }; # Make sub returning pair
Trey