Fixing C's Biggest Mistake
Steven Schveighoffer
schveiguy at gmail.com
Thu Dec 22 14:50:23 UTC 2022
On 12/22/22 3:26 AM, GrimMaple wrote:
> This thing right here
> https://dlang.org/spec/hash-map.html#static_initialization has been "Not
> YET implemented" for as long as I work with D (that's more than 3
> years), and it doesn't seem to be bothering anyone. But yes,
> implementing a compiler inside a compiler is much more important, when
> the original compiler doesn't even work properly.
I have a (clunky) library solution:
https://github.com/schveiguy/newaa
You can build one of those at compile-time, and use it at runtime, and
it can be explicitly converted to/from builtin AA (without any copying),
because it's binary compatible.
e.g.
```d
import std.stdio;
import schlib.newaa;
Hash!(string, int) aa = ["hello": 1, "world": 2];
void foo(int[string] x)
{
x["blah"] = 5;
}
void main()
{
foo(aa.asAA);
writeln(aa["blah"]); // 5
}
```
-Steve
More information about the Digitalmars-d
mailing list