Ruling out arbitrary cost copy construction?

Michel Fortin michel.fortin at michelf.com
Sun Oct 31 06:04:12 PDT 2010


On 2010-10-30 23:56:24 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> Walter and I discussed the matter again today and we're on the brink of 
> deciding that cheap copy construction is to be assumed. This simplifies 
> the language and the library a great deal, and makes it perfectly good 
> for 95% of the cases. For a minority of types, code would need to go 
> through extra hoops (e.g. COW, refcounting) to be compliant.

A simple question: can a reference counter work with const and immutable?

	const(S) func(ref const(S) s) {
		return s; // this should increment the reference counter, but can we 
bypass const?
	}

Bypassing const/immutable could work, but if your data is immutable and 
resides in read-only memory you'll get a crash.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list