Larry Wall wrote:
> 
> : In summary: assuming Perl 6 allows user-defined while-ish structures, how
> : would it be done?
> 
> I think the secret is to allow easy attachment of regex rules to sub
> and parameter declarations.  There's little point in re-inventing
> regex syntax using declarations.  The whole point of making Perl 6
> parse itself with regexes is to make this sort of stuff easy.
> 
> Larry

Ah. I'd been wondering how Damian's 

      sub if (bool $condition, &block);

was going to be extended to handle if-else, if-elsif, if-elsif-else, if-elsif-elsif, 
if-elsif-elsif-else, etc. 

I *think* what you're saying is that user defined while-ish and if-ish constructs 
should really be created by altering the Perl 6 parser at compile time. Of course, 
that's not really news: you already said that in Apocalypse N (for some value of N 
(I'm to lazy to determine which, since it doesn't matter (and besides, laziness is one 
of my cardinal virtues :-) (parse *that* if you can -- don't smileys just play havoc 
with parenthesis-counting?)))).

I was provoked to ask my question about C<while> by Damian's message which said, in 
part:

> So C<if>'s signature is:
> 
>         sub if (bool $condition, &block);

Now, if I'm understanding correctly, *that* turns out not to be the case. Of course, 
Damian's point was to talk about semicolons after blocks, not C<if> structures in all 
their glorious complexity. Nonetheless, the signature of C<if> in Perl 6 will have to 
be more complicated than that, or it wouldn't be able to handle zero-or-more elsif's 
and zero-or-one else's. 

Again quoting Damian:
> Likewise I could write my own C<perhaps> subroutine:
> 
>         sub perhaps (bool $condition, num $probability, &block) {

This, on the other hand, would be true. The simplicity of this hypothetical control 
structure makes it possible to use the built-in syntactic features of Perl 6 
(especially the rules concerning blocks and how they interact with commas and 
semicolons), so it wouldn't be necessary to extend the grammar to implement C<perhaps>.

Am I getting this straight?
=thom

Reply via email to