> Date: 20 Jan 2003 20:30:07 -0000 > From: Smylers <[EMAIL PROTECTED]> > > It seems that when chaining together functions, omitting C<< <~ >> > operators gives the same result in the familiar Perl 5 standard > function-call syntax: > > @foo = sort { ... } <~ map { ... } <~ grep { ... } <~ @bar; > @foo = sort { ... } map { ... } grep { ... } @bar; > > Left-right pipelines make sense to me. I'm not yet sure how much I'd > use them, but there are times when I find it a little odd to have data > flowing 'upstream' in code, and reversing this could be nifty.
Agreed. > However right-left pipelines don't seem to add much to the language, > while becoming something else to have to learn and/or explain. > (Damian's explanation of what C<< <~ >> does to code seemed > significantly more involved than that of C<< ~> >>.) It's simple: it's a backwards dot. The invocant goes on the right and the method and arguments go on the left. $foo.bar($baz); -or- bar $foo: $baz; is the same as: bar $baz <~ $foo; And you see now what this gives us. It gives us the ability to place the invocant (almost) anywhere we want: On the left, in between, or on the right. I think it's fortunate that we can't put it between arguments... > And an alternative spelling for the assignment operator[*0] doesn't > strike me as something Perl is really missing: > > $msg <~ 'Hello there'; > $msg = 'Hello there'; Yeah, I didn't see much gain in this bit. But it's an expectable generalization from ~>. > I realize that there's a symmetry between the two operators, but that > isn't a convincing reason for having them both. People are used to data > flow in one direction; it seems reasonable only to have an operator when > wanting to change this, to make it go in the opposite direction. > > What benefit does C<< <~ >> bring to the language? Again, it provides not just a "null operator" between to calls, but rather a rewrite of method call syntax. So: map {...} <~ grep {...} <~ @boing; is not: map {...} grep {...} @boing; But rather: @boing.map({...}).grep({...}); Which will be defined to mean the same thing, but in many cases this won't be true. Another example: print "Starting server\n" <~ open "> $logfile"; The important thing is that it's starting the server, not that it's writing that to the logfile. I personally think that this could add something to readability at times. Maybe not as much as ~>, but every once in a while. Luke