NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Operator overloading to describe pipelines (Score:1)
I looked into doing something very much along those lines some time ago (during OSCON::EU 2006 in Brussels, I think).
One of the problems is that callers which do
use warningswill get lots of “Useless use of bitwise or (|) in void context” warnings. I considered whether this sort of thing would alleviate the problem:It would, through the surprising scope of
*^H, but there’s an obvious disadvantage: you don’t get any other void-context warnings.I was additionally trying to get
<,>, and>>to work as redirection operators. That turned out to be even trickier: things likewon’t work because of operator precedence. Perl conveniently warns you about this: “Possible precedence problem on bitwise | operator”; whether that’s actually better than the alternative is debatable in this case.
Finally, I believe it’s also impossible to use
pipeas the convenience function name for these purposes:That’s by no means an insuperable objection, of course. For that matter, the other issues can all be worked around to produce a good interface, but it’s particularly annoying that what seems initially to be an ideal interface isn’t apparently implementable.
Reply to This
Re: (Score:1)
I wouldn’t particularly care about the redirection operators. I would rather let the desugared API handle the more complex cases than try to stuff them all into symbols.
The warning is an annoyance, I agree.