checked in changeset 1962 (opDispatch is cool!).
Note that this does not completely replicate the original functionality. The
original was unsafe for builtin appending, this one is safe, but may yield
strange results.
For example:
auto str = "abcdefg".idup;
auto app = appender(&str);
str ~= "hijk";
assert(app.data == "abcdefg"); // on previous version, app.data would have
"abcdefghijk"
app.put("lmnop");
assert(str == "abcdefglmnop"); // on previous version, str would read
"abcdefghijklmnop"
Since we can't hook builtin array appending, RefAppender cannot tell when it
has
been used. Any use of builtin append will reallocate anyways.
I'd recommend examining any code that uses appender(&arr) to make sure it
doesn't also use builtin append on the array while using the appender. Such
behavior was unsafe for the original version of Appender anyways.
-Steve
----- Original Message ----
> From: Steve Schveighoffer <[email protected]>
> To: Discuss the phobos library for D <[email protected]>
> Sent: Tue, September 7, 2010 7:26:25 AM
> Subject: Re: [phobos] Appender
>
> The old method is completely different from the new one, I'm not storing a
> pointer to an array in the implementation struct.
>
> I'll see if I can wrap the appender functionality. I'll add back the
> appender
>
> signature below, it will just return something different than
> Appender!(T[]),
> which shouldn't be a problem as long as you use auto.
>
> -Steve
>
>
>
> ----- Original Message ----
> > From: David Simcha <[email protected]>
> > To: Discuss the phobos library for D <[email protected]>
> > Sent: Sun, September 5, 2010 10:36:26 PM
> > Subject: [phobos] Appender
> >
> > Guys,
> >
> > Can we add back the appender signature appender(T)(T[]* arr) as a
>deprecated
>
> >function? I'm trying to compile some libraries (specifically Orange) that
> >depend on this. IMHO it was used enough by existing code that it needs to
>be
>
> >deprecated rather than immediately removed w/o warning.
> >
> > --Dave
> > _______________________________________________
> > phobos mailing list
> > [email protected]
> > http://lists.puremagic.com/mailman/listinfo/phobos
> >
>
>
>
> _______________________________________________
> phobos mailing list
> [email protected]
> http://lists.puremagic.com/mailman/listinfo/phobos
>
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos