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

via Digitalmars-d digitalmars-d at puremagic.com
Mon Sep 15 06:15:27 PDT 2014


On Monday, 15 September 2014 at 09:50:30 UTC, monarch_dodra wrote:
> On Monday, 15 September 2014 at 02:26:19 UTC, Andrei 
> Alexandrescu wrote:
>> So, please fire away. I'd appreciate it if you used RCString 
>> in lieu of string and note the differences. The closer we get 
>> to parity in semantics, the better.
>>
>>
>> Thanks,
>>
>> Andrei
>
> ***Blocker thoughts***
> (unless I'm misunderstood)
>
> - Does not provide Forward range iteration that I can find. 
> This makes it unuseable for algorithms:
>     find (myRCString, "hello"); //Nope
> Also, adding "save" to make it forward might not be a good 
> idea, since it would also mean it becomes an RA range (which it 
> isn't).

No, RA is not implied by forward.

>
> - Does not provide any way to (even "unsafely") extract a raw 
> array. Makes it difficult to interface with existing functions. 
> It would also be important for "RCString aware" functions to be 
> properly optimized (eg memchr for searching etc...)

Another perfect use case for borrowing...

> ***Extra thoughts***
> There have been requests for non auto-decoding strings. Maybe 
> this would be a good opportunity for "RCXUString" ?

Yes. I'm surprised by this proposal, because I thought Walter was 
totally opposed to a dedicated string type. If it now becomes 
acceptable, it's a good opportunity for moving away for 
auto-decoding.


More information about the Digitalmars-d mailing list