Initialization of std.typecons.RefCounted objects
Christophe Travert
travert at phare.normalesup.org
Thu Jul 19 01:14:25 PDT 2012
"monarch_dodra" , dans le message (digitalmars.D:172700), a écrit :
> I think it would be better to "initialize on copy", rather than
> default initialize. There are too many cases an empty array is
> created, then initialized on the next line, or passed to
> something else that does the initialization proper.
Not default-initializing Array has a cost for every legitimate use of an
Array. I think people use Array more often than they create
uninitialized ones that are not going to be used before an other Array
instance is assigned to them, so Array would be more efficient if it was
default initialized and never check it is initialized again. But that's
just speculation.
> You'd get the correct behavior, and everything else (except dupe)
> works fine anyways.
Keeping the adress of the content secret may be a valuable intention,
but as long as properties and opIndex does not allow to correctly
forward methods, this is completely broken. Is there even a begining of
a plan to implement this? I don't see how properties or opIndex could
safely forward methods that uses references and that we do not control
without escaping the reference to them. That's not possible until D has
a complete control of escaping references, which is not planned in the
near or distant future. Not to mention that having a complete control of
escaping reference break lots of code anyway, and might considerably
decrease the need for ref counted utilities like... Array.
Please, at least give me hope that there is light at the end of the
tunnel.
--
Christophe
More information about the Digitalmars-d
mailing list