On Fri, 6 Jun 2003 18:16:26 +0100, Rob Dixon <[EMAIL PROTECTED]> wrote:

John W. Krahn wrote:
Mark Anderson wrote:
>
> B) You should NEVER use map in a void context.  map works very hard
>    to build up it's return value, so there should be an assignment
>    (=) operator to the left of your map call almost always, otherwise
>    all of that work is wasted.

I would never say NEVER as there are some situations where it may be
appropriate, just like there are some situations where goto is
appropriate.

Sure, but I can't for the moment think of any difference between


foreach (LIST) BLOCK
or
EXPRESSION foreach LIST

and

map BLOCK LIST
or
map EXPRESSION, LIST

in void context. Any thoughts?

Rob

Mark explained the difference. map has the overhead of building the list that it returns. foreach doesn't. In Kevin's example a list containing "01" .. "12" is created and never used. It's inefficient.


Katy



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to