Hello,
I have a wish for Perl6. I think it would be nice to have the possibility
for more than one modifier after a simple statement.
For example:
print $a+$b if $a if $b for 1..3;
Gerd Pokorra
E-Mail: pok...@uni-siegen.de
(I'm surprised that the message was accepted, even)
perl6-language-re...@perl.org skribis 2004-06-25 13:38 (-0000):
> I have a wish for Perl6. I think it would be nice to have the possibility
> for more than one modifier after a simple statement.
Has been discussed more than once already. Please read the older
messages first.
http://www.mail-archive.com/perl...@perl.org/msg27900.html
> print $a+$b if $a if $b for 1..3;
The double if doesn't make a lot of sense. What's wrong with "and"?
print $a + $b if $a and $b for 1..3;
Or, with just one statement modifier, as "if" is just a fancy "and" (or
vice versa):
$a and $b and print $a + $b for 1..3;
Juerd
There are two kind of modifiers, loop modifiers and simple test
modifiers.
It is unpossible to stack loop modifiers without adding
conventions denoting the iterators. One could use as many
underscores as the depth of the iterator. Countins underscore
would not be a problem knowing that a depth of more than three is
probably pathologic. Note that this convention could go as well
for embedded normal loop without contextualizers.
print "$_ $__ " for 'a'.. 'b' for 1..2
would print
1a 1b 2a 2b
Consecutive test modifiers can be replaced by a C<or> or a
C<and>, or better by a C<||> or <C&&> because the alphabetic
version looks too much like a modifier.
But too much stacking of modifiers is probably not a good idea.
My own take would be to support at most two modifiers of
different kind per statement That is at most one loop modifier
and at most one simple test modifier per statement.
But, in previous mails, Larry ruled for at most one modifier.
--
stef
Is it really? I've always thought this would be useful enough:
say .{foo} for @$_ for @foo;
Although that can probably just be written as:
say .{foo} for @<<@foo; # Looks strange. Is this correct?
Juerd
Not so sure, but maybe. It certainly looks weird.
I like to think of hyperoperators in terms of map. So for some unary
operator §:
§«@x
Is equivalent to:
map { §$_ } @x
So it appears that:
say .{foo} for @«@foo;
Would work, but I'd be much more comfortable with:
say .{foo} for *«@foo;
For reasons I can't describe. :-)
Luke
>
> I have a wish for Perl6. I think it would be nice to have the possibility
> for more than one modifier after a simple statement.
Larry's ruled that it's one statement modifier per statement, period. For
anything else you'd need to modify the grammar. (Which won't be difficult)
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk