On Wed, Jan 18, 2012 at 11:37 PM, Andreas Rossberg <[email protected]>wrote:
> On 19 January 2012 07:51, Mark S. Miller <[email protected]> wrote: > > Everyone on this thread, is there any need expressed in this thread that > is > > not satisfied by InfiniteMap? > > Looks good, except that I don't understand why you want a lazyFactory > function instead of a simple initialValue -- if you recommend > lazyFactory having no observable side effect, then (with no arguments) > it will be a constant function, and you could as well use a plain > value. > > On the other hand, a function would be useful if it also got the key > as an argument, so that it can manufacture values in a key-dependent > manner. I think providing the key, or the key and defaultValue as Andrea suggests is a fine idea. However, even without these, the answer to your question is "fresh mutable state" as in function lazyFactory() { return Set(); } or similarly function lazyFactory() { return []; } etc This addresses the only concrete use cases I've seen mentioned in this thread -- using nested single-key single-valued collections to emulate either a) multi-valued collections, i.e., MultiMaps, as single-valued collections from keys to sets of values, or b) multi-keyed collections, i.e., a two dimensional map, as a map from a first key to a collection mapping from a second key (array index) to a value. -- Cheers, --MarkM
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

