Escaping the Tyranny of the GC: std.rcstring, first blood

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 24 22:46:28 PDT 2014


On 9/24/2014 1:15 PM, Manu via Digitalmars-d wrote:
> Something like (whatever syntax you like):
>
> int^ rcInt; // refcounted pointer to an int
> MyStruct^ rcStruct; // refcounted pointer to a struct
> MyStruct s; // normal value-type struct, but if the struct has
> opInc/opDec, the RC handling code in the compiler can implicitly
> generate calls to opInc/opDec on assignment, which will allow the
> struct to manage itself.

I think Microsoft's C++/CLI tried that mixed pointer approach, and it was a 
disaster. I don't have personal knowledge of this.

I suspect I know why. C++ on DOS had mixed pointer types - the near and far 
thing. It was simply unworkable in C++. Sure, it technically worked, but was so 
awful trying to deal with "is my ref type near or far" that people just couldn't 
write comprehensible code with it.

Note that a ^ pointer will be a different size than a * pointer. Things go 
downhill from there.


More information about the Digitalmars-d mailing list