Andrei Alexandrescu Wrote: > dsimcha wrote: > > == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > >> Jason House wrote: > >>> Andrei Alexandrescu Wrote: > >>> > >>>> grauzone wrote: > >>>>> Walter Bright wrote: > >>>>>> We both feel that this would simplify D, make it more flexible, > >>>>>> and remove some awkward corner cases like the inability to say > >>>>>> a.length++. > >>>>> How would this remove this corner case? > >>>> Can't increment length if it's read-only. > >>>> > >>>> Andrei > >>> removing syntactic sugar doesn't really remove corner cases. T[new] > >>> is being replaced with an array builder. What usage semantics are > >>> given up with an array builder? How will implicit conversions be > >>> handled? (alias this, etc...). How will the Phobos array buiilder > >>> support user specified lengths (for efficiency)? > >> I think ArrayBuilder could a logic similar to Appender for "~=" and > >> otherwise offer regular array primitives. I don't think implicit > >> conversion to T[] is an essential feature, but it can be done. > >> Andrei > > > > So basically, ArrayBuilder would be like T[new], except: > > > > 1. It would be a plain old library type, and the core language would know > > nothing > > about it. > > 2. T[].dup, T[] ~ T[], new T[3], etc. would return T[], not > > ArrayBuilder/T[new]. > > > > Is this basically correct? > > Yes, that's the plan. I hope you're not setting me up or something :o). > > Andrei
I was ;) Well, only sort of. I'm undecided if array-like syntactic sugar makes sense for array builder. Afterall, AA's fit into a similar category. I did notice you wanted to make array builder a struct which implies it won't be used in the same manner as T[new]