AA behaves differently in CTFE?
Bastiaan Veelo via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 24 11:43:08 PST 2015
On Tuesday, 24 November 2015 at 14:23:38 UTC, Steven
Schveighoffer wrote:
> If CTFE associative arrays perform differently, then that is a
> bug. I am not sure if this is the case, but you should file a
> bug anyway, someone can take a look at it.
>
> If you can narrow it down to a minimal case where it breaks
> down, that would be helpful.
>
> -Steve
Thanks. After narrowing it down further I discovered a mistake in
my code, which caused undesired behaviour dependent on the order
in which elements on an AA are traversed by foreach.
As it turns out, the order in which foreach traverses elements of
an AA at compile time differs from the order at run time. So yes,
associative arrays behave differently, but it is hardly a bug
since "in a foreach loop the order in which the elements are
iterated is unspecified." [1]
[1] http://dlang.org/hash-map.html
More information about the Digitalmars-d-learn
mailing list