DMD 0.173 release
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sun Nov 5 12:49:29 PST 2006
Ok, so this one is about a feature of some releases ago, but you're
releasing new features faster than what we can keep up and look at :P
Regarding array literals, it concerns me that each new literal
"evaluation" will create a new instance. For example a literal inside a
function will allocate a new instance every time the function is called.
Likewise a literal inside a loop will allocate a new instance for every
cycle of the loop!
This strikes me as both inefficient (as there is no simple way to use
the opposite behavior: static/global instances) and inconsistent: other
kinds of literals, like string literals, are not instanced per
"evaluation" but instead are single/global/static instances.
Is there any particular reason for this behavior? Because if not I'm
inclined to think it would be better that array literals work as string
literals (global/static instances). If the new'ed-instance behavior is
needed it could be easily emulated with dup'ing:
ar = [1, 4, 9].dup;
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d-announce
mailing list