> Luke Palmer wrote: > > [quote from A4] > > To me, this looks like it has answers to all these questions. > > Up to a point. Look at the discussion of given/when in the same > Apocalypse. Here's some example code from A4: > > > given $! { > when Error::Overflow { ... } > when Error::Type { ... } > when Error::ENOTTY { ... } > when /divide by 0/ { ... } > ... > } > > Look, closing braces, ending statements, not on a line by > themselves. There's code like this all through the apocalypse and its > associated Exegesis, so it looks to me like C<< rx/\} \s* \n/ >> is > the regex for 'end of statement'. Either that or we're back with a > pile of special cases, which I thought the Apocalypse was supposed to > be eliminating.
That's because C<when>s are statements. Statements don't need to be terminated. In C (or even Perl 5) you don't need to write: if (a < b) { foo(); }; That's because the grammar says that conditionals (and loops) are statements all by themselves, because this doesn't make sense: 1 + if (a < b) { foo(); } / 2; But in Perl 6, things are moving around. Perl 6 needs the ability for users to program such interfaces with subs, which I<are> expressions. So, according to Damian, if a sub's last argument is a closure, it can (but not necessarily will) act like a statement rather than an expression. >From what I understand of his message, this has nothing to do with whitespace. I don't know the exact semantics, if they are what I think they are, then I disagree. sub cond_if ($condition, &code) {...} # returns something cond_if ($x < $y) { $y } for @a; @b; @c; # ... This requires infinite lookahead to parse. Nobody likes infinite lookahead grammars. Personally, I liked the A4 decision the best ('}' on a line by itself), and I think otherwise there's too many ambiguities like this one. However, if an elegant solution has been (or is going to be) found, I'm all ears. Luke