Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: is the use of map in a void context deprecated ?

by Zaxo (Archbishop)
on Oct 05, 2003 at 18:31 UTC ( #296747=note: print w/replies, xml ) Need Help??


in reply to is the use of map in a void context deprecated ?

Void map has never been deprecated in the official sense that pseudo-hashes, v-strings, and $* are. Maybe a better word would be derided. The map function produces a copy of the post-map list which is useless in void context and immediately thrown away. Optimizers dislike that, particularly when a for loop can do better.

I seem to recall that map was just rewritten to check for void context and avoid the extra work if possible. That would remove all objections but aesthetic ones, shouts of "Ugly!" which need not be listened to. I'll try to remember where I saw that.

After Compline,
Zaxo

  • Comment on Re: is the use of map in a void context deprecated ?

Replies are listed 'Best First'.
Re: Re: is the use of map in a void context deprecated ?
by liz (Monsignor) on Oct 05, 2003 at 18:57 UTC
    ...I seem to recall that map was just rewritten to check for void context and avoid the extra work if possible.

    That is correct. And it's in Perl 5.8.1! From the 5.8.1. perldelta:

    "map" in void context is no longer expensive. "map" is now context aware, and will not construct a list if called in void context.

    Liz

      I didn't know perldelta('s), we can learn a lot from it ...
      Let me sharing this :
      "Switch", by Damian Conway, has been added. Just by saying :
      use Switch;
      Fore more information on this module :
      $ perldoc Switch

      Thanks Liz and Zaxo for answering,

      Arnaud
        It's just a source filter though, and while it tries really hard to parse Perl, only perl really can. F.ex, I (only accidentally) discovered it was causing a spurious problem for someone else a while ago that seemed to be completely unrelated.

        Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://296747]
help
Chatterbox?
[LanX]: naaah! Putin wouldn't nuke all the Russians in Berlin
[Your Mother]: Putin is a bad guy but heís not that kind of bad guy. (Who would launch.)
[erix]: fortunately, Putin seems to be ill -- or at least, they're building a hospital for him and his cronies in Moscow
[erix]: nobody knows what kind it takes :)
[erix]: I say his seems a face that launches a thousand missiles :)
[Your Mother]: I say I do. :P
[Your Mother]: Missiles would be an idiotís play. Putin is many things but he is not an idiot.
[erix]: I like the idea of the trumps troup of imbeciles growing slightly nervous now their incompetence will be tested
[erix]: you seem forget there is another idiot coming :)
[Your Mother]: The US government does not attract talent, but grafters and liars and it has been that way for the better part of a century. FEW exceptions.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-01-20 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (173 votes). Check out past polls.