Opportunities for D

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 8 20:26:54 PDT 2014


On Wednesday, 9 July 2014 at 03:18:54 UTC, Brad Anderson wrote:
> Well, for starters RefCounted doesn't work with classes. That
> needs to be implemented. I'm not sure what was problematic about
> implementing it for classes though (anyone reading know?).

idk if this is what the Phobos devs were thinking, but my own 
attempts have hit a few snags:

1) double indirection with the naive solution: struct { Object o; 
int refcount; }. Pretty easily fixed by emplacing the class 
though so no big deal but phobos didn't seem to attempt this so 
maybe that was a problem there.

2) It messes up implicit casting. And this is a big deal because 
I don't think there's a solution: alias this can help with the 
base class, but can't handle the multiple requirements of classes 
that implement several interfaces.

If you alias this to the payload, it would accomplish 
everything... but then the reference is no longer counted, 
allowing it to escape and still point to freed memory.

Multiple alias this is prolly a solution to the problem.

> Secondly, a lot of things need to be extracted from std.grabbag
> (AKA std.typecons) and put in modules with names that are much
> more obvious. Nobody thinks to check "typecons"

yea I think most people don't even know this stuff exists.


More information about the Digitalmars-d mailing list