Containers

Per Nordlöw per.nordlow at gmail.com
Wed Sep 1 20:38:42 UTC 2021


On Wednesday, 1 September 2021 at 02:08:40 UTC, max haughton 
wrote:
> We need better containers to compete with other languages. On 
> top of that, there are patterns that other languages cannot do. 
> One thing that comes to mind is how D is one of not many 
> languages (languages with macros or similar probably can), that 
> can easily allow one to write containers which lie about their 
> layout. The most profitable example of that I can think of is 
> automatically switching arrays of POD types to be a struct of 
> arrays internally. This transformation makes random access to 
> elements slower, however (say) loops where access to a subset 
> of the elements dominates then this is much faster due to 
> improved cache efficiency.

Great point. Game engines extensively use such data layouts when 
storing vertex data. That's reason for Jai wanting a builtin SoA 
type. Jai has interestingly since made that a library feature.


More information about the Digitalmars-d mailing list