On Wednesday, 7 October 2015 at 10:44:50 UTC, Jonathan M Davis wrote:
Having ref-counting built into the language will allow us to make it more efficient and provide some safety guarantees that can't necessarily be provided in a struct, but it doesn't make it so that no one can misuse ref-counted objects.

I doubt that it can gain much performance in contrast to a well-designed scope-like feature. In particular, elision of inc/dec pairs is practically free in such a system.


Ultimately, the largest benefit to having ref-counting built into the language will probably be that we can the have exceptions be reference counted [...]

Why not allow throwing structs if they subtype Throwable (via alias this)? This is less whacky than it sounds at first: During the throwing process, no postblit's don't have to be called, because throwing always just moves. Destruction and copying can only take place in catch blocks, where it's already supported. There would probably just be minor changes necessary to druntime and the compiler.

Reply via email to