On Mon, Sep 15, 2008 at 12:16:22PM +0200, Moritz Lenz wrote:
: Chris Davaz wrote:
: I'm not sure if it's anywhere in the specs, but I was expecting to be able
: to do this:
:
: .say for =$in unless $foo;
:
: to quote http://perlcabal.org/syn/S04.html#Loop_statements
:
: :Looping statement modifiers are the same as in Perl 5 except that, for
: :ease of writing list comprehensions, a looping statement modifier is
: :allowed to contain a single conditional statement modifier:
: :
: :@evens = ($_ * 2 if .odd for 0..100);
:
:
: Where we have multiple modifiers, here for and unless. Is this in the
: specs? If yes, is it supposed to work in pugs or rakudo? If it's not in the
: specs can we add it? ;-)
:
: The authoritative source to ask if a piece of text is valid Perl 6 is
: STD.pm. It parses your example, but not as you might expect. Output from
: STD5_dump_match
:
: :Unknown routines:
: :unless called at 1
: :comp_unit:
: : statementlist:
: : statement:
: : EXPR:
: :noun:
: : dotty:
: : .
: : dottyop:
: : methodop:
: :longname:
: : name:
: : identifier:
: : say
: :
: : statement_mod_loop:
: :for
: :modifier_expr:
: : EXPR:
: : pre:
: : prefix:
: :=
: : noun:
: : variable:
: :sigil:
: : sigil:
: : $
: :desigilname:
: : longname:
: : name:
: : identifier:
: :in
: :
: : statement:
: : EXPR:
: :noun:
: : term:
: : unless
: : args:
: :
: : arglist:
: :EXPR:
: : noun:
: : variable:
: : sigil:
: :sigil:
: : $
: : desigilname:
: :longname:
: : name:
: : identifier:
: : foo
: : ;\n
:
: So 'unless' is actually parsed as a sub call.
That's obviously a bogus parse, and I even know how it happened
(because unless is currently considered a terminator that doesn't
distinguish between expression termination and statement termination),
but I'm not sure how to fix it yet. It's possible that statement
modifiers should be demoted to very-low-precedence operators, but there
are some problems with that that I don't have enough brain to think
through at the moment.
Larry