Damian Conway writes:
> Buddha Buck wrote:
> >
> > Perl 5 allows you to do:
> >
> > $object->meth1->meth2->meth3; # Perl5 chained method, L2R
> >
> > Perl 6 will also allow you to do:
> >
> > $data ~> sub1 ~> sub2 ~> sub3; # Perl6 chained subs, L2R
> >
> > Perl 5 allows you to to:
> >
> > sub3 sub2 sub1 $data; # Perl5 chained subs, R2L
> >
> > Perl 6 will also allow you to do:
> >
> > meth3 <~ meth2 <~ meth1 <~ $Xbject # Perl 6 chained methods, R2L
> >
> > All four syntaxes will be available in Perl 6, modulo the fact that '->'
> > is now spelled '.'
> >
> > The additional functionality that when the last sub or method in the ~>
> > and <~ is a variable an assigment is done is a convenience issue.
>
will something like that work ? and how ~> distinguish between = and
:= ?
@source ~> part [
/foo/,
/bar/,
/zap/ ]
~> (@foo,@bar,@zap)
the issue is : what happens if function returns more than one
variables .
It seems that it is not very bad idea to have some special (lexical )
variable similar to $0 for regexes that is set after
grep/part/sort/or_may_be_something_userdefined have done its work and
then ( here $0 is a placeholder for that variable ) :
@source ~> part [
/foo/ => @foo,
/bar/ => @bar
/zap/ => @zap ] ;
$0{'@foo'} ~> map { ... } ~> @foo;
$0{'@bar'} ~> map { ... } ~> @bar;
$0{'@zap'} ~> map { ... } ~> @zap;
but maybe that may be stilll shortened . the idea ( maybe bad ) is to
have "named" or "numbered" (pseudo)pipes similar to having named or
numbered arguments.
@source |> part [
/foo/ => "foo",
/bar/ => "bar"
/zap/ => "zap" ]
|foo> map { ... } |> @foo,
|bar> map { ... } |> @bar,
|zap> map { ... } |> @zap ;
So |foo> is "undone" by perl arranging temporal variable after the
action of part and then feeding this temporal variable to the rest of
pipeline. that also means that |foo> "remembers" the return values
_only_ from the thing on its _closest_ left .
then something like that can be made to work :
@source |> grep { ... }
|ok> map { ... } |> @foo,
|nok> map { ... } |> @bar ;
I am not sure this is a good solution
but I think that "purge" and L2R-R2L threads of this maillist have to
be more close somehow.
arcadi