On Thursday, 8 August 2013 at 23:19:49 UTC, bearophile wrote:
Ali Çehreli:
More than that. :) enums are manifest constants.
Imagine that enum as being pasted into source code as is. This
used to have surprising effects for AAs, as an enum AA would
be instantiated from scratch everywhere that AA enum was used
in the code.
I think that some time ago Don has proposed to disallow the
'enum' tag for things like AAs, on the base that such behavour
is not efficient, surprising, and maybe even not useful... I
don't know where his proposal has gone later.
Bye,
bearophile
Enum trick is useful to workaround bug with aggregate members of
reference types being initialized - all instances share reference
to same data and to enable default struct constructors.