On Saturday, September 01, 2012 00:12:06 ixid wrote: > Hmm, you mean if you call the same function it creates a new copy > every time? I misunderstood you to mean it creates it once at > each site in the code it's called.
enum values are basically copy-pasted everywhere that they're used. So, if you have something like enum arr = [1, 2, 3, 4 5]; auto a = arr; auto b = arr; auto c = arr; it's effectively identical to auto a = [1, 2, 3, 4, 5]; auto b = [1, 2, 3, 4, 5]; auto c = [1, 2, 3, 4, 5]; as opposed to actual variable such as auto arr = [1, 2, 3, 4, 5]; auto a = arr; auto b = arr; auto c = arr; In this case, each variable is actually a slice of the same array rather than duplicating the value. Using an enum is particularly bad for an AA, since it's not exactly a simple data type, and there's definitely some cost to constructing them. - Jonathan M Davis
