Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

more than one modifier

1 view
Skip to first unread message

Unknown Sender

unread,
Jun 25, 2004, 9:38:46 AM6/25/04
to perl6-l...@perl.org

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

Juerd

unread,
Jun 25, 2004, 10:08:05 AM6/25/04
to perl6-l...@perl.org, pok...@uni-siegen.de
Please configure your email client correctly.

(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

Stéphane Payrard

unread,
Jun 25, 2004, 4:15:59 PM6/25/04
to perl6-l...@perl.org
On Fri, Jun 25, 2004 at 03:38:51PM +0200, perl6-language-return-17601-stef=payra...@perl.org wrote:
>
>
> 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

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

Juerd

unread,
Jun 25, 2004, 10:18:29 AM6/25/04
to Stéphane Payrard, perl6-l...@perl.org
Stéphane Payrard skribis 2004-06-25 16:15 (-0400):

> It is unpossible to stack loop modifiers without adding
> conventions denoting the iterators.

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

Luke Palmer

unread,
Jun 25, 2004, 3:08:24 PM6/25/04
to Juerd, Stéphane Payrard, perl6-l...@perl.org

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

Dan Sugalski

unread,
Jun 28, 2004, 9:54:38 AM6/28/04
to perl6-l...@perl.org
On -1 xxx -1, it was written:

>
> 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

0 new messages