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

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 19 03:32:37 PDT 2014


On Wednesday, 17 September 2014 at 16:32:41 UTC, Andrei 
Alexandrescu wrote:
> On 9/17/14, 9:30 AM, Dicebot wrote:
>> Ironically, strings have been probably least of my GC-related 
>> issues
>> with D so far - hard to evaluate applicability of this 
>> proposal because
>> of that. What are typical use cases for such solution? (not 
>> questioning
>> its importance, just being curious)
>
> Simplest is "I want to use D without a GC and suddenly the 
> string support has fallen down to bear claws and silex stones."
>
> RCString should be a transparent (or at least near-transparent) 
> replacement for string in GC-less environments.

Well this is exactly what I don't understand. Strings we have 
don't have any strong connection to GC (apart from concatenation 
which can be verified by @nogc) being just slices to some 
external buffer. That buffer can be malloc'ed or stack allocated, 
that doesn't really affect most string processing algorithms, not 
unless those try to do some re-allocation of their own.

I agree that pipeline approach does not work that well for 
complex programs in general but strings seem to be best match to 
it - either you want read-only access or a pipe-line, everything 
else feels inefficient as amount of write operations gets out of 
control. Every single attempt to do something clever with shared 
CoW strings in C++ I have met was a total failure.

That is why I wonder - what kind of applications really need the 
rcstring as opposed to some generic rcarray?


More information about the Digitalmars-d mailing list