"Don" <x...@nospam.com> wrote in message 
news:bdmmimwuqsgphgprd...@forum.dlang.org...
>
> IIRC the poor performance of array literals and AA literals is because 
> they're not always literals, sometimes they are variables (!) and the 
> compiler assumes the worst case. You are allowed to write:
>
> void foo(int some_param)
> {
>     immutable string[int] = [ 1: "abc", some_param: "def"];
> }
>
> I wish we could get rid of that silliness entirely.
>
>
> If the members are compile-time expressions, you probably want to mark the 
> variable as static const/static immutable.

Yeah, IIRC the missing piece is putting AAs in the data segment so they can 
cross from compile to run-time with out an aaliteral call.  At least then we 
could use enum aas in runtime code without allocating.

It would be great if we could make aa literals default to immutable (array 
literals too), and force adding .dup to get a mutable version.


Reply via email to