I find it amazing that you find five characters (the space is optional) for lambdas too long -- heck, the proper name of the feature is longer then that.
I've given this a bit of thought: it's not so much the sub {...} part that I find verbose as the fact that I can't bind variables in a convenient way: I either have to use up keystrokes with a my ($x,$y,$z) = @_; at the front of the lambda, or constantly index @_ (which looks awful).
For instance, in Haskell the "zip" function (take a pair of lists and return a list of pairs) is defined as:
(What's important here is the lambda.) In Perl, assuming an equivalent zipWith, you'd have to say:zip = zipWith (\x y -> (x,y))
none of which looks as pretty. That's more a matter of opinion, of course.zipWith {[$_[0], $_[1]]} @foo, @bar; # or: zipWith {($a,$b)=@_;[$a,$b]} @foo, @bar; # or: zipWith {[unshift,unshift]} @foo, @bar;
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
% man 3 strfry
In reply to Re^2: Indispensible language features
by FoxtrotUniform
in thread Indispensible language features
by FoxtrotUniform
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |