Disadvantages of ARC

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Feb 6 08:25:34 PST 2014


On 2/6/14, 7:22 AM, Sönke Ludwig wrote:
> I'm just not convinced (far from it) that Phobos should be built on top
> of such an RCSlice type. I rather strongly agree with Dicebot that the
> API should be extended to work with ranges or pre-allocated buffers
> where possible + support for custom allocators where it makes sense. How
> the memory is managed is then totally up to the user and no Phobos
> function needs to be aware of that (e.g. just pass in a pre-allocated,
> reference counted slice).

That makes sense. One possibility I was thinking about was to make 
Phobos largely transparent wrt types trafficked and simply return the 
type received. Consider:

// lib code
struct RCSlice(T) { ... }
alias rcstring = RCSlice!(immutable char);
rcstring rc!(string s) { ... }

// user code
auto s1 = buildPath!("hello", "world");
auto s2 = buildPath!(rc!"hello", rc!"world");

In this example s1 will have type string and s2 will have type rcstring.

There are of course functions that would need to be given hints as to 
the output type.


Andrei



More information about the Digitalmars-d mailing list