https://issues.dlang.org/show_bug.cgi?id=9491
w0rp <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from w0rp <[email protected]> --- I know exactly the kind of thing you are talking about. What you want is a setDefault function with an overload. These functions should have these signatures. ref V1 setDefault(K, V1, V2)(ref V1[K] map, K key, lazy V2 value) if (is(V2 : V1)); ref V setDefault(K, V)(ref V[K] map, K key); Where the second overload is equivalent to setDefault(map, key, V1.init) above. This is basically 'setdefault' from Python, only better because the value is lazy. I have written a higher level implementation of this myself before, but I believe a druntime implementation could do better by computing a hash for K once, like you say. --
