Struct that destroys its original handle on copy-by-value

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 31 11:52:44 PDT 2015


On Friday, 31 July 2015 at 18:23:39 UTC, H. S. Teoh wrote:
> It seems that what the language (originally) defines structs to 
> be, is not entirely consistent with how it has come to be used 
> (which also entailed later extensions to the struct 
> definition), and this has been a source of problems.

Yes, and it wasn't because people started to misuse structs - it 
was because certain designs would be simply impossible otherwise. 
The very language design assumption that structs should always be 
dumb copyable values was not practical. It may come from times 
when GC, heaps and classes were considered "good enough for 
everyone" and RAII intended to be completely replaces by 
scope(exit). Which didn't work.


More information about the Digitalmars-d-learn mailing list