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:
zip = zipWith (\x y -> (x,y))
(What's important here is the lambda.) In Perl, assuming an
equivalent zipWith, you'd have to say:
zipWith {[$_[0], $_[1]]} @foo, @bar;
# or:
zipWith {($a,$b)=@_;[$a,$b]} @foo, @bar;
# or:
zipWith {[unshift,unshift]} @foo, @bar;
none of which looks as pretty. That's more a matter of
opinion, of course.
--
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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.