Associative arrays
Steven Schveighoffer
schveiguy at gmail.com
Tue May 18 12:57:01 UTC 2021
On 5/18/21 7:54 AM, Adam D. Ruppe wrote:
> On Tuesday, 18 May 2021 at 09:41:06 UTC, Ola Fosheim Grostad wrote:
>> It could look the same, but long[string] would now be a shorthand for
>> std.xyz.Map!(long,string) or something like that instead of a special
>> case.
>
> It would actually be really cool if the AA literal was just rewritten
> into a constructor call of key, value, key, value, ....
>
>
> _d_aa_literal(T...)(T args) // pragma(discardable) too would be nice
>
> [4: "hello", 6: "bye"]
>
> _d_aa_literal(4, "hello", 6, "bye")
>
>
> Then you can construct it at ctfe and it retains the order and the
> capability of heterogeneous types. It'd be overpowered to an awesome
> extent... and would fix that annoying static initialization of AA things.
Let's make that 2 arrays (static or stack-allocated dynamic) to avoid
the vararg template cost.
-Steve
More information about the Digitalmars-d
mailing list