Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-23 Thread Jon D via Digitalmars-d-learn
On Tuesday, 24 November 2015 at 01:00:40 UTC, Steven Schveighoffer wrote: On 11/23/15 7:29 PM, Ali Çehreli wrote: On 11/23/2015 04:03 PM, Steven Schveighoffer wrote: > On 11/23/15 4:29 PM, Jon D wrote: >> In the example I gave, what I was really wondering was if there is a >> difference

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-23 Thread Ali Çehreli via Digitalmars-d-learn
On 11/23/2015 04:03 PM, Steven Schveighoffer wrote: > On 11/23/15 4:29 PM, Jon D wrote: >> In the example I gave, what I was really wondering was if there is a >> difference between allocating with 'new' or with 'reserve', or with >> 'length', for that matter. That is, is there a material

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/15 4:29 PM, Jon D wrote: On Monday, 23 November 2015 at 15:19:08 UTC, Steven Schveighoffer wrote: On 11/21/15 10:19 PM, Jon D wrote: On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis wrote: Honestly, arrays suck as output ranges. They don't get appended to; they get

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/23/15 7:29 PM, Ali Çehreli wrote: On 11/23/2015 04:03 PM, Steven Schveighoffer wrote: > On 11/23/15 4:29 PM, Jon D wrote: >> In the example I gave, what I was really wondering was if there is a >> difference between allocating with 'new' or with 'reserve', or with >> 'length', for

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/21/15 10:19 PM, Jon D wrote: On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis wrote: Honestly, arrays suck as output ranges. They don't get appended to; they get filled, and for better or worse, the documentation for copy is probably assuming that you know that. If you want

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-23 Thread Jon D via Digitalmars-d-learn
On Monday, 23 November 2015 at 15:19:08 UTC, Steven Schveighoffer wrote: On 11/21/15 10:19 PM, Jon D wrote: On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis wrote: Honestly, arrays suck as output ranges. They don't get appended to; they get filled, and for better or worse, the

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 22, 2015 03:19:54 Jon D via Digitalmars-d-learn wrote: > On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis > wrote: > > > > Honestly, arrays suck as output ranges. They don't get appended > > to; they get filled, and for better or worse, the documentation > > for

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jon D via Digitalmars-d-learn
On Sunday, 22 November 2015 at 00:10:07 UTC, Ali Çehreli wrote: May I suggest that you improve that page. ;) If you don't already have a clone o the repo, you can do it easily by clicking the "Improve this page" button on that page. Hi Ali, thanks for the quick response. And point taken :) I

copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jon D via Digitalmars-d-learn
Something I found confusing was the relationship between array capacity and copy(). A short example: void main() { import std.algorithm: copy; auto a = new int[](3); assert(a.length == 3); [1, 2, 3].copy(a); // Okay int[] b; b.reserve(3); assert(b.capacity >=

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Ali Çehreli via Digitalmars-d-learn
Hi Jon! :) On 11/21/2015 03:34 PM, Jon D wrote: > Preconditions: > target shall have enough room to accomodate the entirety of source. > > Clarifying that "enough room" means 'length' rather than 'capacity' > might be beneficial. May I suggest that you improve that page. ;) If you

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 21, 2015 23:34:25 Jon D via Digitalmars-d-learn wrote: > Something I found confusing was the relationship between array > capacity and copy(). A short example: > > void main() > { > import std.algorithm: copy; > > auto a = new int[](3); > assert(a.length == 3);

Re: copy and array length vs capacity. (Doc suggestion?)

2015-11-21 Thread Jon D via Digitalmars-d-learn
On Sunday, 22 November 2015 at 00:31:53 UTC, Jonathan M Davis wrote: Honestly, arrays suck as output ranges. They don't get appended to; they get filled, and for better or worse, the documentation for copy is probably assuming that you know that. If you want your array to be appended to when