Thread overview
[phobos] Appender
Sep 06, 2010
David Simcha
September 05, 2010
  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
September 07, 2010
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 <dsimcha at gmail.com>
> To: Discuss the phobos library for D <phobos at puremagic.com>
> 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
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
> 



September 07, 2010
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 <schveiguy at yahoo.com>
> To: Discuss the phobos library for D <phobos at puremagic.com>
> 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 <dsimcha at gmail.com>
> > To: Discuss  the phobos library for D <phobos at puremagic.com>
> > 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
> > phobos at puremagic.com
> >  http://lists.puremagic.com/mailman/listinfo/phobos
> > 
> 
> 
> 
> _______________________________________________
> phobos  mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>