Time to kill T() as (sometimes) working T.init alias ?
Jonathan M Davis
jmdavisProg at gmx.com
Fri Nov 30 20:43:25 PST 2012
On Saturday, December 01, 2012 15:32:39 Walter Bright wrote:
> On 11/30/2012 3:31 PM, Mehrdad wrote:
> > If that's the case, then we need to get rid of postblits entirely.
>
> The only justification I've ever been able to come up with for postblits
> is implementing a reference counting type.
Any struct which contains reference types needs them. For instance, a struct
containing int[] needs to dup that array if it doesn't want to have the copy
referring to the same elements as the original and therefore risk having them
be mutated. Arrays with immutable elements don't have that problem, but those
with mutable elements (and to some extent those with const) do have such a
problem, as to structs with classes or structs which are reference types, etc.
I'm surprised that you'd think that postblit constructors were only useful for
implementing reference counting types. IMHO, the language would be crippled
without a postblit or copy constructor for structs.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list