AA literals/initialisation
Daniel Murphy
yebblies at nospamgmail.com
Tue Nov 12 02:00:15 PST 2013
"Don" <x at nospam.com> wrote in message
news:bdmmimwuqsgphgprdngh at 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.
More information about the Digitalmars-d
mailing list