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
gt;> same thing as a C++ std::vector, or a Java/.Net ArrayList, etc. My view as well. >> And D >> "array slices" (the proper term IMO) are not the same. Exactly! >> I'm willing to change the article to mention "Array slices" instead of >> just &q

Re: Slices and Dynamic Arrays

2018-01-02 Thread Jonathan M Davis via Digitalmars-d-learn
Net ArrayList, etc. And D > "array slices" (the proper term IMO) are not the same. > > I'm willing to change the article to mention "Array slices" instead of > just "slices", because that is a valid criticism. But I don't want to > change it from sl

Re: Slices and Dynamic Arrays

2018-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
a valid criticism. But I don't want to change it from slices to dynamic arrays, since the whole article is written around the subtle difference. I think the difference is important. -Steve [1] https://en.wikipedia.org/wiki/Dynamic_array

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

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 >

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

Re: Slices and Dynamic Arrays

2017-12-31 Thread Jonathan M Davis via Digitalmars-d-learn
uffer > > the dynamic array instead of calling T[] the dynamic array like > > the language and spec do. Regardless, all non-null dynamic > > arrays are slices of memory. > > The DLang Tour also uses the term slice to refer to T[]. > > "The type of arr is int[], whi

Re: Slices and Dynamic Arrays

2017-12-31 Thread Tony via Digitalmars-d-learn
. Regardless, all non-null dynamic arrays are slices of memory. The DLang Tour also uses the term slice to refer to T[]. "The type of arr is int[], which is also called a slice." "A slice consists of two members - a pointer to the starting element and the length of the slice:"

Re: Slices and Dynamic Arrays

2017-12-31 Thread Jonathan M Davis via Digitalmars-d-learn
quot; 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 > - Slice

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
y 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 sa

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

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
- 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 would pref

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

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

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"