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 ?
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2014-09-24 04:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (245 votes), past polls