Static associative array expressions

Stefan Koch uplink.coder at googlemail.com
Mon Sep 20 12:54:34 UTC 2021


On Monday, 20 September 2021 at 12:38:59 UTC, Steven 
Schveighoffer wrote:
> On 9/19/21 9:38 AM, Stefan Koch wrote:
>> On Sunday, 19 September 2021 at 11:55:04 UTC, Steven 
>> Schveighoffer wrote:
>>> On 9/19/21 1:43 AM, Stefan Koch wrote:
>>>
>>>> What do you guys think?
>>>
>>> I think an easier fix is just to change the call that does 
>>> the AA literals to something that can be CTFEd. Right now 
>>> it's an extern(C) hook that is opaque and takes void[] and 
>>> TypeInfos.
>>>
>>> Something like:
>>>
>>> ```d
>>> V[K] __aALiteral(V, K)(K[] keys, V[] values);
>>> ```
>>>
>>> Then just lower the call to that, and if that is CTFEable, it 
>>> works.
>>>
>> 
>> That puts actually more pressure on CTFE to be able to adapt 
>> to different layouts.
>
> CTFE doesn't have to use runtime AAs internally, only when 
> moving to code generation would it have to call this function.
>
>> Also it introduces yet more templates, I cannot cache 
>> templates as effectively as I can runtime which I only have to 
>> generate once.
>
> Only one template per AA type.
>
> -Steve

But that would be an interpreted/or some day JITed function call 
that has to do the hashing of the values and place them into the 
right buckets.
Which would be a different function per instance.

Whereas currently the only thing that has to be interpreted is 
the toHash function.
and it only has to be called once per element.


More information about the Digitalmars-d mailing list