[Issue 2954] [tdpl] Allow to set associative array key value only using expression AA key type is constructable from
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 27 17:44:01 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=2954
--- Comment #17 from Steven Schveighoffer <schveiguy at gmail.com> ---
(In reply to hsteoh from comment #16)
> Niche or not, this problem ought to be fixed. It's been how long now, and we
> still haven't gotten our act together on AA's.
You may misunderstand, what I'm talking about is an update-like function, but
allows you to tell it how to store the key as well as the value. It's not as
easy to model as the current `update` function, because on create, you need to
give it both key and value. so something like:
`void updateWithKey(V[RealKey] aa, RealKey function(LookupKeyType k)
makeKeyOnCreate, V function() valueOnCreate, V function(RealKey)
valueOnUpdate)`
This issue itself is not niche and needs to be fixed as the P1 that it is. I
was just talking about a piece of missing functionality to avoid double lookups
in this situation (wanting to only do an expensive thing -- e.g. allocate --
when creating a new key/value pair).
--
More information about the Digitalmars-d-bugs
mailing list