Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^6: Order in which grep/map receive elements

by abufct (Initiate)
on Oct 06, 2012 at 01:22 UTC ( #997560=note: print w/replies, xml ) Need Help??

in reply to Re^5: Order in which grep/map receive elements
in thread Order in which grep/map receive elements

+ self describing code
+ behavior is guaranteed by module docs
- needs a module (but I have it on our servers already)

- unobvious construct
- behavior might change in future versions of perl (although that's unlikely)
- declares auxiliary variable that might interfere with other code

The choice is quite obvious to me. :-)

  • Comment on Re^6: Order in which grep/map receive elements

Replies are listed 'Best First'.
Re^7: Order in which grep/map receive elements
by Tanktalus (Canon) on Oct 06, 2012 at 04:11 UTC

    Er... hmm.

    uniq is self describing, check. That it documents this is a bonus, but it kind of falls out of the fact that grep is implicitly documented this way. As in, when order isn't going to come out the same way, it's documented that it won't, otherwise assume it will. And needing a module is not an issue.

    grep, on the other hand, is not "unobvious". The behaviour won't change in future versions of perl. It can't change. The perl devs care way too much about backward compatibility, so it can't change. And the auxiliary variable is self-scoped. Again, not an issue.

    So, to me, uniq barely eeks out a win simply on self-describing. Which is why I use it.

    Though you missed one point: because List::MoreUtils also comes with XS-based implementations, it can also be faster than using grep. This might matter to you. It doesn't matter to me, so it doesn't make my list of pros, but if it matters to you, you can add that as a plus. Assuming that it was compiled - I've never seen it not compiled, but presumably there may be situations where it isn't.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997560]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-07-18 19:02 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (393 votes). Check out past polls.