Luke Palmer writes:
> > Date: Mon, 9 Dec 2002 06:00:40 +0100
> > From: St�phane Payrard <[EMAIL PROTECTED]>
>
> > Damian:
> > > so it's easy to build up more complex right-to-left pipelines, like:
> > >
> > > (@foo, @bar) :=
> > > part [/foo/, /bar/],
> > > sort { $^b <=> $^a }
> > > grep { $_ > 0 }
> > > @data;
> > >
> > >
> >
> > I would like perl6 to support left-to-right part/sort/grep pipelines.
> > Left to right syntax is generally good because it facilitates the flow
> > of reading.
> >
> > For these pipelines, the current right to left syntax is due to the emphasis
> > on the operation over the data operated on, so the operator appears
> > first. Nevertheless with a long pipeline, data is best factored out in a
> > variable so having it first is not an impediment.
> [snip]
>
> I was just playing with Mathematica and thinking this very same thing.
> Mathematica has an operator // that applies arguments on the left to
> the function on the right. I was just thinking how good that was for
> clarity. To do some awful computation, and get a numeric result, you
> can write:
>
> N[awful computation]
>
> Or:
>
> awful computation // N
some time ago there was some discussion in that direction . Larry told
he leke to put arguments before the function name and than he began to
talk about japaneese . I was trying to push ~~ operator for exactly
this purpose . but Larry explained that ~~ is first of all for the
purpose of returning meaningful boolean .
I really like the idea of pipe-like syntax .
Mathematica have another operator that seems to be nice ( and not used
yet in perl ) :
@students /. sort { $^a.grade <=> $^b.grade }
/. head 5 ;
interesting, I proposed then ~> for that purpose : fusion of ~~ and
-> . but ~> is ugly , I admit .
so
$x /. foo # foo( $x )
$x /. foo /. bar # bar( $x /. foo ) # bar( foo( $x ) )
maybe /. should be just infix form of given
given $x , &foo ;
given ( given $x , &foo ) , &bar ;
but then proper Unix pipe |. should probably be infix form of "for" ...
for @x , &foo ;
for ( for @x , &foo ) , &bar ;
@x |. &foo
@x |. &foo |. &bar
infix form of "if" *is* already in language .
if $x { &foo } else { &bar };
$x ?? { &foo } :: { &bar };
arcadi