this(this) must be cheap and O(1)
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Sep 24 05:36:08 PDT 2011
On 9/24/11 6:30 AM, Trass3r wrote:
>> This means that objects with large state would need to use things like
>> COW and/or reference counting.
>
> Isn't an expensive-to-copy type supposed to be a class anyway?
Well not always - see BigInt.
>> I'd go as far as requiring this(this) to be nothrow, but perhaps it
>> would be best to see whether that is a necessity.
>
> Don't memory allocations prevent a function from being nothrow?
A nothrow function may allocate memory, but allocating inside this(this)
would be a faux pas.
> Then this would make it impossible to properly wrap an array in a struct.
COW would help there.
Andrei
More information about the Digitalmars-d
mailing list