Re: The analogue of "fill-pointer" in D

2015-05-19 Thread Kagamin via Digitalmars-d-learn
On Monday, 18 May 2015 at 16:40:30 UTC, Dennis Ritchie wrote: On Monday, 18 May 2015 at 12:49:56 UTC, Kagamin wrote: Filling a buffer is usually done this way: http://dlang.org/phobos/std_stdio.html#.File.rawRead Here such example, the task. There is a flow stream, associated, for example, wi

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 05/18/2015 11:52 AM, Steven Schveighoffer wrote: > Also note that the longest slice doesn't necessarily have access to > appending. All that is required is that the slice end lands on the array > end: That explains a lot. Thanks. Ali

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 2:45 PM, Ali Çehreli wrote: Exactly! That recent discovery of mine made me come up with this guideline: "Never append to a parameter slice." I think this may not be an appropriate guideline. It's perfectly fine to append to a parameter slice. You just need to leave it the way you f

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 2:40 PM, Ali Çehreli wrote: On 05/18/2015 11:19 AM, John Colvin wrote:> On Monday, 18 May 2015 at 17:43:50 UTC, Ali Çehreli wrote: >> On 05/18/2015 05:26 AM, John Colvin wrote: >>> On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC,

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 18 May 2015 at 17:14:46 UTC, Steven Schveighoffer wrote: capacity is analogous to the number of elements in the vector (as returned by array-dimension according to https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node162.html). arr.length is analogous to the fill pointer. example: i

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 05/18/2015 10:52 AM, Steven Schveighoffer wrote: > On 5/18/15 1:43 PM, Ali Çehreli wrote: >> void main() >> { >> auto a = new int[20]; >> foo(a); >> //can't now append to a > > Well, sure you can :) > > a ~= 5; // works fine > > But I understand you mean that an append to 'a' w

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 05/18/2015 11:19 AM, John Colvin wrote:> On Monday, 18 May 2015 at 17:43:50 UTC, Ali Çehreli wrote: >> On 05/18/2015 05:26 AM, John Colvin wrote: >>> On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: > No, afrai

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 17:43:50 UTC, Ali Çehreli wrote: On 05/18/2015 05:26 AM, John Colvin wrote: On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers!

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 1:43 PM, Ali Çehreli wrote: On 05/18/2015 05:26 AM, John Colvin wrote: On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers! It's exactly the sa

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Ali Çehreli via Digitalmars-d-learn
On 05/18/2015 05:26 AM, John Colvin wrote: On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers! It's exactly the same. But in D capacity is affected by o

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote: On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 11:40:13 UTC, thedeemon wrote: On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers! It's exactly the same. But in D capacity is affected by other things. auto a = new int[20]; auto b =

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Kagamin via Digitalmars-d-learn
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: It seems to be nonsense. But this is nonsense, ideal for buffers. If the buffer is implemented as an array, then fill pointer just marks the boundary of the filled part of the buffer, and adding a buffer (moving away from the fill p

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread John Colvin via Digitalmars-d-learn
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_arrays.htm Does D some equivalent? Fill pointers, combined with the various helper functions (e.g. vector-push) and

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/15 6:24 AM, Dennis Ritchie wrote: On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote: On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_arrays.htm Does D som

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 18 May 2015 at 12:49:56 UTC, Kagamin wrote: Filling a buffer is usually done this way: http://dlang.org/phobos/std_stdio.html#.File.rawRead Here such example, the task. There is a flow stream, associated, for example, with any socket. It wrote several bytes at a time. To once again

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread thedeemon via Digitalmars-d-learn
On Monday, 18 May 2015 at 10:24:25 UTC, Dennis Ritchie wrote: No, afraid not. Function capacity is not an analogue of fill-pointers! It's exactly the same. Lisp-programmer explains the usefulness of fill-pointers as follows: "Fill pointer "cuts" the tail of the vector. In D: .length "cut

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Kagamin via Digitalmars-d-learn
On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_arrays.htm Does D some equivalent? Data stored in the array is indicated by the array length property, use capacity

Re: The analogue of "fill-pointer" in D

2015-05-18 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 18 May 2015 at 10:14:33 UTC, Kagamin wrote: On Monday, 18 May 2015 at 08:21:38 UTC, Dennis Ritchie wrote: Hi, In Common Lisp, there is such a thing as a fill-pointer (Example 5): http://www.tutorialspoint.com/lisp/lisp_arrays.htm Does D some equivalent? Data stored in the array