--- "Joseph F. Ryan" <[EMAIL PROTECTED]> wrote:
> If the final design stays the way it is now, there really won't be
> a "lexer". Instead, a perl6 grammar parses the data, and builds up
> a huge match-object as it, well, matches. This match object is then
> munged into the optree.
>
With this in mind, I'll say it again:
Let's support separable verbs.
Here's how:
# Note my arbitrary selection of _ as separation indicator. Feel free
to replace this with something more appropriate:
sub if ($test, &block)
_ elsif ($test, &block) is optional is floating is multi
_ elsunless ($test, &block) is optional is floating is multi
_ else (&block) is optional is fixed
{
while (!$args[0].test) shift;
&args[0].block();
}
Where:
1: I'm hacking real hard on the implementation. Better Ideas Welcome.
2: space-underscore-space means "separable bit". Negotiable. BIW.
3: is optional/[dflt: required] means doesn't have to appear.
4: is floating/[dflt: fixed] means can appear in any order.
5: is multi/[dflt: single] means can appear more than once.
The last three (3, 4, 5) are really just match-hints to the rexer for
"here's how to look for me":
/if <arg-bits>
((elsif <arg-bits> | elsunless <arg-bits>)*)
(else <arg-bits>)?/
Instead of, say, requiring all the elsif in front of all the elsunless,
or whatever.
I think this is one of those p6-ish generalizations:
try/catch/finally
do/while
if/elsif/elsunless/else
repeat/until
(arguably: switch/case/default)
are all just separable verbs:
sub try (&block)
_ catch ($e, &block) is optional is multi is fixed
_ finally (&block) is optional is fixed;
sub do (&block)
_ while ($cond); # is single is fixed is required
sub repeat (&block)
_ until ($cond); # is single is fixed is required
sub switch ($cond)
_ case ($val, &block) is multi is required
_ default (&block) is optional;
(Note: This leaves switch statements looking like crap, so I'd really
rather sugar them up. But the point is, you *could* to it that way.)
switch ($x)
case (10) { print 10; }
case (11) { print 11; }
default { print "Something else"; }
=Austin