Long have I been a fan of giving pure Perl modules the power to change the rules and 
create a more built-in look, feel, and functionality. So, of course, I love %MY, I 
love real named parameters, I love the ability to create iterators that look just like 
native control structures. But while laying in bed (which I should be doing now) a 
thought occured to me.

How would I create an itertor in pure Perl 6 which worked like a C style for, now 
loop? Pondering this, these vaguely related thoughts passed through my mind:

1. We now have the super comma,which can sperate arguements, so at least that looks 
right. But without changing the parsing rules, can I make the lack of a comma between 
the (...) and the block not an error?

2. This still won't work beacuse the three expressions will be evaluated before being 
passed to the iterator. I could get around this by having them be passed at strings 
and evaling them, but that defeats the idea of writing a control structure that's 
bulit in. What feature would Perl 6 have to have to make this possible? I remembered 
the ugly pass by name thread that I ignorantly started earlier, and realized that 
being able to hold the expression's evaluation until it's used makes it the perfect 
fit for this sort of thing. Can someone please show me I'm wrong and that this can be 
accomplished without pass by name?

3. Finally, if the above we're no longer issues,I realized that it would be easy to 
write an iterator that breaks our golden rule of blocks - lexical scope should not 
leak. I'm not yet adept at Perl 6 enough to write out an example of such an iterator, 
but it would be a simple matter of eva;uating the initial arg to loop, checking %MY to 
cee what lexicals were created, and then monkeying with the %MY of the closure passed 
to the iterator as a final argument. Is this an issue, or can does it fall under the 
"a use declaration makes a prgram a Perl 'dialect' and is free to break the rules"?
-Erik


Is your boss reading your email? ....Probably
Keep your messages private by using Lycos Mail.
Sign up today at http://mail.lycos.com

Reply via email to