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

Manu via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 25 00:10:50 PDT 2014


On 25 Sep 2014 15:50, "Walter Bright via Digitalmars-d" <
digitalmars-d at puremagic.com> wrote:
>
> 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.

C++ doesn't have any notion of borrowing. Scope can (will?) fix a whole lot
of existing problems, and also allow RC -> raw pointers work nicely.

Also, I have no experience that leads me to believe it was any sort of
disaster. It would have been nice if it didn't imply com specifically,
that's probably the real problem that got the bad press; ^ pointers are
implicitly com, which I don't recommend repeating ;)

> 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.

I don't think this is the same thing. There's a practical and functional
difference. People would definitely use it if they have it.

I don't think the MS problem was in any way related.

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

Dynamic arrays are a different size from pointers, that never caused any
problems. I can't imagine any issues from this.

Anyway, it hasn't been explored at length. If it has any chance then I'll
put extensive thought into it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140925/c9c46103/attachment.html>


More information about the Digitalmars-d mailing list