Re: Is mimicking a reference type with a struct reliable?

2010-10-16 Thread Steven Schveighoffer
On Sat, 16 Oct 2010 12:59:46 -0400, Denis Koroskin <2kor...@gmail.com> wrote: Sorry, I misclicked a button and send the message preliminary. On Sat, 16 Oct 2010 20:16:40 +0400, Steven Schveighoffer wrote: A final option is to disable the copy constructor of such an unsafe appender, but

Re: Is mimicking a reference type with a struct reliable?

2010-10-16 Thread Denis Koroskin
Sorry, I misclicked a button and send the message preliminary. On Sat, 16 Oct 2010 20:16:40 +0400, Steven Schveighoffer wrote: A final option is to disable the copy constructor of such an unsafe appender, but then you couldn't pass it around. What do you think? If you think it's worth h

Re: Is mimicking a reference type with a struct reliable?

2010-10-16 Thread Steven Schveighoffer
On Sat, 16 Oct 2010 12:23:50 -0400, Denis Koroskin <2kor...@gmail.com> wrote: No, it doesn't use capacity, it uses length as a capacity instead: void ensureCapacity(T)(ref T[] array, size_t minCapacity) { size_t capacity = array.length; if (minCapacity < capacity) {

Re: Is mimicking a reference type with a struct reliable?

2010-10-16 Thread Denis Koroskin
On Sat, 16 Oct 2010 20:16:40 +0400, Steven Schveighoffer wrote: On Sat, 16 Oct 2010 11:52:29 -0400, Denis Koroskin <2kor...@gmail.com> wrote: First I'd like to say that I don't really like (or rather use) Appender because it always allocates (at least an internal Data instance) even wh

Re: Is mimicking a reference type with a struct reliable?

2010-10-16 Thread Steven Schveighoffer
On Sat, 16 Oct 2010 11:52:29 -0400, Denis Koroskin <2kor...@gmail.com> wrote: First I'd like to say that I don't really like (or rather use) Appender because it always allocates (at least an internal Data instance) even when I provide my own buffer. I mean, why would I use Appender if it st

Is mimicking a reference type with a struct reliable?

2010-10-16 Thread Denis Koroskin
irst I'd like to say that I don't really like (or rather use) Appender because it always allocates (at least an internal Data instance) even when I provide my own buffer. I mean, why would I use Appender if it still allocates? Okay, you have to store a reference to an internal representation