Luke Palmer <[EMAIL PROTECTED]> writes:

> This is for everyone: <<EOA4
>
>    In  Perl,  this  problem comes up most often when people say "Why do I
>    have  to  put  a semicolon after do {} or eval {} when it looks like a
>    complete statement?"
>    
>    Well, in Perl 6, you don't, if the final curly is on a line by itself.
>    That  is,  if  you  use  an expression block as if it were a statement
>    block,  it  behaves as one. The win is that these rules are consistent
>    across  all  expression  blocks, whether user-defined or built-in. Any
>    expression  block  construct can be treated as either a statement or a
>    component  of an expression. Here's a block that is being treated as a
>    term in an expression:
>     $x = do {
>               ...
>     } + 1;
>
>    However, if you write
>     $x = do {
>               ...
>     }
>     + 1;
>    then  the + will be taken erroneously as the start of a new statement.
>    (So don't do that.) 
>    
>    Note  that  this  special  rule only applies to constructs that take a
>    block (that is, a closure) as their last (or only) argument. Operators
>    like  sort  and  map  are unaffected. However, certain constructs that
>    used  to be in the statement class may become expression constructs in
>    Perl 6. For instance, if we change BEGIN to an expression construct we
>    can  now  use a BEGIN block inside an expression to force compile-time
>    evaluation of a non-static expression:
>     $value = BEGIN { call_me_once() } + call_me_again();
>
>    On  the  other  hand,  a  one-line  BEGIN  would  then  have to have a
>    semicolon.
>
> EOA4
>
> 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.

-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?

Reply via email to