[phobos] I think we need to make an emergency release
Andrei Alexandrescu
andrei at erdani.com
Wed Aug 25 13:47:35 PDT 2010
On 8/25/10 12:48 PDT, Steve Schveighoffer wrote:
> One very very notable difference from the original appender is it does not take
> a pointer as the parameter. This means it does not update the original array
> you pass to it (well, it does, but will not modify the length).
I don't think this is good. When you format stuff you do want to append
the formatted result incrementally to the string.
> Other than that, here is the updated API (with private data shown for an idea of
> how the implementation works):
>
> struct Appender(A : T[], T)
> {
> private struct Data
> {
> size_t capacity;
> Unqual!(T)[] arr;
> }
>
> private Data* _data;
I think this looks good - why not make arr of type pointer to array and
support append to existing arrays?
> /**
> Construct an appender with a given array. Note that this does not copy the
> data, but appending to the array will copy the data, since Appender does not
> know if this data has valid data residing after it. The initial capacity will
> be
> arr.length.
> */
> this(T[] arr);
Appender was partly created to avoid the issue the comment warns about.
Andrei
More information about the phobos
mailing list