Re: Slices and Dynamic Arrays

2018-01-02 Thread Ali Çehreli via Digitalmars-d-learn
On 01/02/2018 11:17 AM, Jonathan M Davis wrote: > On Tuesday, January 02, 2018 10:37:17 Ali Çehreli via Digitalmars-d-learn > wrote: >> For these reasons, the interface that the program is using is a "slice". >> Dynamic array is a different concept owned and implemented by the GC. > > Except that

Re: Slices and Dynamic Arrays

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 10:37:17 Ali Çehreli via Digitalmars-d-learn wrote: > As soon as we call it "dynamic array", I can't help but think "adding > elements". Since GC is in the picture when that happens, it's essential > to think GC when adding an element is involved. > > Further, evident

Re: Slices and Dynamic Arrays

2018-01-02 Thread Ali Çehreli via Digitalmars-d-learn
First, I'm in complete agreement with Steve on this. I wrote a response to you yesterday, which I decided to not send after counting to ten because despite being much more difficult, I see that your view can also be aggreable. On 01/02/2018 10:02 AM, Jonathan M Davis wrote: > On Tuesday, Jan

Re: Slices and Dynamic Arrays

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 02, 2018 07:53:00 Steven Schveighoffer via Digitalmars- d-learn wrote: > On 1/1/18 12:18 AM, Jonathan M Davis wrote: > > A big problem with the term slice though is that it means more than just > > dynamic arrays - e.g. you slice a container to get a range over it, so > > that r

Re: Slices and Dynamic Arrays

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/1/18 12:18 AM, Jonathan M Davis wrote: A big problem with the term slice though is that it means more than just dynamic arrays - e.g. you slice a container to get a range over it, so that range is a slice of the container even though no arrays are involved at all. So, you really can't rely

Re: Slices and Dynamic Arrays

2018-01-01 Thread Seb via Digitalmars-d-learn
On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote: On Sunday, December 31, 2017 14:49:40 Tony via Digitalmars-d-learn wrote: On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis wrote: > [...] The DLang Tour also uses the term slice to refer to T[]. "The type of arr i

Re: Slices and Dynamic Arrays

2017-12-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 01, 2018 05:06:46 Tony via Digitalmars-d-learn wrote: > On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote: > > The DLang Tour should probably be fixed to use the term dynamic > > array though. > > Or embrace both terms but take care that it is clear that they > ar

Re: Slices and Dynamic Arrays

2017-12-31 Thread Tony via Digitalmars-d-learn
On Monday, 1 January 2018 at 02:10:14 UTC, Jonathan M Davis wrote: The DLang Tour should probably be fixed to use the term dynamic array though. Or embrace both terms but take care that it is clear that they are synonyms and one may be preferred depending on context. As a beginner, I had s

Re: Slices and Dynamic Arrays

2017-12-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 31, 2017 14:49:40 Tony via Digitalmars-d-learn wrote: > On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis > > wrote: > > The D Slices article does an excellent job of explaining all of > > this. It's just that it calls the GC-allocated memory buffer > > the dynamic a

Re: Slices and Dynamic Arrays

2017-12-31 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 14:24:40 UTC, Jonathan M Davis wrote: The D Slices article does an excellent job of explaining all of this. It's just that it calls the GC-allocated memory buffer the dynamic array instead of calling T[] the dynamic array like the language and spec do. Regardl

Re: Slices and Dynamic Arrays

2017-12-31 Thread Jonathan M Davis via Digitalmars-d-learn
mic array" as > synonyms. My initial impression was that they must have different > code underlying them, and different behavior. I would pick one or > the other. It should be: > > D Arrays >- Static > - Dynamic > > or > > D Arrays > - Static >

Re: Slices and Dynamic Arrays

2017-12-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 31, 2017 04:42:01 Tony via Digitalmars-d-learn wrote: > On Sunday, 31 December 2017 at 04:20:28 UTC, codephantom wrote: > > On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote: > >> On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley > >> > >> wrote: > >>> double[] D

Re: Slices and Dynamic Arrays

2017-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/30/17 10:08 PM, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is?  :D An approximation of a slice of pi. -Steve

Re: Slices and Dynamic Arrays

2017-12-31 Thread Steven Schveighoffer via Digitalmars-d-learn
memory it references. Normally you would consider a dynamic array to own its memory (i.e. be responsible for allocation and destruction). Because we have the GC, ownership can be fuzzy. The DLang Tour has a section on Slices that says in bold "Slices and dynamic arrays are the

Re: Slices and Dynamic Arrays

2017-12-30 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 04:20:28 UTC, codephantom wrote: On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote: On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a sli

Re: Slices and Dynamic Arrays

2017-12-30 Thread codephantom via Digitalmars-d-learn
On Sunday, 31 December 2017 at 03:57:17 UTC, Tony wrote: On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a slice of pi" a slice of pi is irrational.

Re: Slices and Dynamic Arrays

2017-12-30 Thread Tony via Digitalmars-d-learn
On Sunday, 31 December 2017 at 03:08:05 UTC, Ivan Trombley wrote: double[] D = [3.14159]; Can you guess what D is? :D It took me a while but I finally came up with "a slice of pi"

Re: Slices and Dynamic Arrays

2017-12-30 Thread Ivan Trombley via Digitalmars-d-learn
double[] D = [3.14159]; Can you guess what D is? :D

Re: Slices and Dynamic Arrays

2017-12-30 Thread Tony via Digitalmars-d-learn
be: D Arrays - Static - Dynamic or D Arrays - Static - Slice The DLang Tour has a section on Slices that says in bold "Slices and dynamic arrays are the same". I think that sentence deserves an explanation as to why there are two terms being utilized for the same thing. I

Re: Slices and Dynamic Arrays

2017-12-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 29, 2017 22:32:01 Tony via Digitalmars-d-learn wrote: > In DLang Tour:Arrays > https://tour.dlang.org/tour/en/basics/arrays > > there is: > --- > int size = 8; // run-time variable > int[] arr = new int[size]; > > The type of arr is in

Re: Slices and Dynamic Arrays

2017-12-29 Thread Muld via Digitalmars-d-learn
On Friday, 29 December 2017 at 22:32:01 UTC, Tony wrote: In DLang Tour:Arrays https://tour.dlang.org/tour/en/basics/arrays there is: --- int size = 8; // run-time variable int[] arr = new int[size]; The type of arr is int[], which is a slice.

Re: Slices and Dynamic Arrays

2017-12-29 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 29 December 2017 at 22:32:01 UTC, Tony wrote: Based on those two web pages it appears that the name for a dynamic array in D is "slice". That is, anytime you have a dynamic array (even a null reference version) it is called a slice. Is that correct? Not exactly, but basically. rea

Slices and Dynamic Arrays

2017-12-29 Thread Tony via Digitalmars-d-learn
In DLang Tour:Arrays https://tour.dlang.org/tour/en/basics/arrays there is: --- int size = 8; // run-time variable int[] arr = new int[size]; The type of arr is int[], which is a slice. --- In "D Slices" htt