Time to kill T() as (sometimes) working T.init alias ?

Jonathan M Davis jmdavisProg at gmx.com
Mon Dec 10 15:41:53 PST 2012


On Monday, December 10, 2012 03:02:40 Walter Bright wrote:
> On 12/9/2012 8:17 PM, Jonathan M Davis wrote:
> > Not to mention, unless you can find ways to implement everything that
> > you'd
> > need a postblit or copy constructor to do without them and get rid of
> > postblits, doing deep copies is going to be possible. And in the process
> > of
> > getting rid of postblits, you could easily end up disallowing other stuff
> > which was useful and innocuous (e.g. something as simple as being able to
> > print out when an object is copied when debugging).
> 
> Have you ever written a struct that requires a deep copy?
> 
> I have, and I always wound up redoing it so the deep copy was unnecessary.

Yes. I've done it. And I don't think that I've ever bothered with COW. The 
extra complication isn't generally worth it as far as I'm concerned. If I've 
really wanted something to be that cheap to copy around, I've usually just 
used a reference type and copied it explicitly when a deep copy was needed.

I have no problem with people using COW if that's what they want to do, and I 
may even use it at some point, but I don't want to be forced to use it in 
order to have structs which hold reference types to be treated as value types.

- Jonathan M Davis


More information about the Digitalmars-d mailing list