Disadvantages of ARC

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Feb 6 10:15:29 PST 2014


On Thu, Feb 06, 2014 at 09:56:14AM -0800, Andrei Alexandrescu wrote:
> On 2/6/14, 9:19 AM, H. S. Teoh wrote:
> >On Thu, Feb 06, 2014 at 04:30:31PM +0000, Dicebot wrote:
> >>On Thursday, 6 February 2014 at 16:25:37 UTC, Andrei Alexandrescu
> >>wrote:
> >>>// 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.
> >>
> >>Looks unnecessary restrictive. Why can't one build rc-string from
> >>stack buffers or Array!char from rc-strings? Type of output buffer
> >>does not have to do anything with input.
> >
> >Agree. Phobos algorithms that populate a data sink should migrate toward
> >using output ranges instead of returning a predetermined type. This will
> >not only address ARC needs, but a bunch of other things as well (output
> >range support/use in Phobos is still rather scanty at the moment).
> 
> I will mention again that output ranges lead to quite a bit more
> code on the caller site. They do give great control, but I'm hoping
> for something more convenient.
[...]

That's only because the current output range API consists of only a
single .put method. Please see the other thread started by Adam Ruppe:
we should spend some time to think about how we can streamline output
ranges so that they can be used just as easily as input ranges --
y'know, with UFCS chaining and such, that doesn't require a ton of
boilerplate like the current process of: declare output range, pass to
function, get data from result, pass to next function, etc.. This is
primarily a syntactical problem, not a logical one, and since we're so
good at syntactic bikeshedding, we should be able to solve this
relatively easily, right? ;-)


T

-- 
Life is unfair. Ask too much from it, and it may decide you don't deserve what you have now either.


More information about the Digitalmars-d mailing list