[comp.lang.icon] Efficiency of the `map' function

Paul_Abrahams@MTS.cc.Wayne.edu (04/08/91)

 
Thanks to all for your informative comments about the efficiency
of the map function.  I had guessed that it might do some caching
of its arguments.  I'm glad to hear that it really does and in
particular that its cache can hold more than one item.
 
I'm still wondering, though, how the map cache works and what its
capacity is.  Is the cache associated with each call or is it
global over the program?  It seems pretty difficult to get a
decent implementation of map without a cache, since each call
requires processing every character in the second argument and
possibly in the third as well.  There does seem to be a hazard
here: writing calls on map that aren't cached and therefore take
a long time to execute.  Not knowing the caching policy, it would
be easy for someone (like me) to inadvertently write a noncached
map call.
 
There's a deeper issue buried here, what some have called
`performance transparency'.  It's the property of a programming
language that enables a programmer to gauge the relative costs of
different constructs.  Certainly someone familiar with the
innards of the Icon implementation can gauge these costs, but as
someone who isn't familiar with the innards, I've always found
that difficult. 
 
Paul Abrahams
abrahams@mts.cc.wayne.edu