Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-15 Thread Mehrdad
On Friday, 15 June 2012 at 07:15:50 UTC, Jonathan M Davis wrote: On Friday, June 15, 2012 09:09:48 Don Clugston wrote: On 10/06/12 23:43, Jonathan M Davis wrote: > On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: >> I honestly don't see the POINT of having a "dynamic array >> literal". >> >> Wh

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-15 Thread Jonathan M Davis
On Friday, June 15, 2012 09:09:48 Don Clugston wrote: > On 10/06/12 23:43, Jonathan M Davis wrote: > > On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: > >> I honestly don't see the POINT of having a "dynamic array > >> literal". > >> > >> What's the point of making the literals dynamic? > >> > >

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-15 Thread Don Clugston
On 10/06/12 23:43, Jonathan M Davis wrote: On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: I honestly don't see the POINT of having a "dynamic array literal". What's the point of making the literals dynamic? They should all be static, and only converted to dynamic if necessary from the contex

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-14 Thread Christophe Travert
"Steven Schveighoffer" , dans le message (digitalmars.D:169718), a écrit : > Note that D1 was like this, [1,2,3] was auto-typed to int[3u]. It was a > constant source of pain that I would not like to revisit. Especially > since static arrays are now passed by value. > > -Steve Since static

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-14 Thread Christophe Travert
Artur Skawina , dans le message (digitalmars.D:169717), a écrit : > On 06/11/12 12:06, Christophe Travert wrote: >> Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit : >>> auto found = find([1, 2, 3, 4, 5], 3); >> >> No problem if the rule could be the following: >> - array liter

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-11 Thread Steven Schveighoffer
On Sun, 10 Jun 2012 20:08:53 -0400, Mehrdad wrote: Type deduction. Exactly. And if they need to be assigned to a static array, then the compiler can automatically do what it needs to do to avoid the extra heap allocation. - Jonathan M Davis "Type deduction"? o.O I don't understand..

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-11 Thread Artur Skawina
On 06/11/12 12:06, Christophe Travert wrote: > Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit : >> auto found = find([1, 2, 3, 4, 5], 3); > > No problem if the rule could be the following: > - array literals are static by default > - array literals are copied to the heap when

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-11 Thread Christophe Travert
Jonathan M Davis , dans le message (digitalmars.D:169705), a écrit : > auto found = find([1, 2, 3, 4, 5], 3); No problem if the rule could be the following: - array literals are static by default - array literals are copied to the heap when assigned to a dynamic array. - the former rule applie

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 05:09:49 Mehrdad wrote: > On Monday, 11 June 2012 at 03:05:36 UTC, Jonathan M Davis wrote: > > What are you trying to fix beyond assignments to static arrays > > with array literals? > > Just the fact that it would reduce unnecessary heap allocations. > I'm not trying to '

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 03:05:36 UTC, Jonathan M Davis wrote: What are you trying to fix beyond assignments to static arrays with array literals? Just the fact that it would reduce unnecessary heap allocations. I'm not trying to 'fix' it though, as it's not broken. (Then again, neither is i

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 04:47:36 Mehrdad wrote: > On Monday, 11 June 2012 at 02:25:54 UTC, Jonathan M Davis wrote: > > Now, since in this particular case, what find returns won't > > ever include anything from any arguments other than the first, > > it'll be fine. > > Yes, that's precisely why yo

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 02:25:54 UTC, Jonathan M Davis wrote: Now, since in this particular case, what find returns won't ever include anything from any arguments other than the first, it'll be fine. Yes, that's precisely why your statement didn't make sense to me. :) But for any temp

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 04:13:42 Mehrdad wrote: > On Monday, 11 June 2012 at 00:57:45 UTC, Jonathan M Davis wrote: > > And if all range-based functions were altered to work with > > static arrays, and we made array literals static, then this > > example would _still_ be broken > > auto found = fin

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 00:57:45 UTC, Jonathan M Davis wrote: And if all range-based functions were altered to work with static arrays, and we made array literals static, then this example would _still_ be broken auto found = find(arr, [1, 2]); Sorry, I don't quite seem to follow. :\ Woul

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 02:45:00 Mehrdad wrote: > On Monday, 11 June 2012 at 00:16:48 UTC, Jonathan M Davis wrote: > > auto found = find(arr, [1, 2]); > > > > wouldn't compile, because [1, 2] would be considered a static > > array, which > > isn't a range. > > > > - Jonathan M Davis > > Uh... t

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
On Monday, 11 June 2012 at 00:16:48 UTC, Jonathan M Davis wrote: auto found = find(arr, [1, 2]); wouldn't compile, because [1, 2] would be considered a static array, which isn't a range. - Jonathan M Davis Uh... that's pretty much just saying, "code that explicitly depends on the current

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 02:08:53 Mehrdad wrote: > >> Type deduction. > > > > Exactly. And if they need to be assigned to a static array, > > then the compiler > > can automatically do what it needs to do to avoid the extra > > heap allocation. > > > > - Jonathan M Davis > > "Type deduction"? o

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
Type deduction. Exactly. And if they need to be assigned to a static array, then the compiler can automatically do what it needs to do to avoid the extra heap allocation. - Jonathan M Davis "Type deduction"? o.O I don't understand... could someone give me an example of what would break

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Monday, June 11, 2012 01:35:41 Timon Gehr wrote: > On 06/11/2012 12:28 AM, Mehrdad wrote: > > Ugh... you keep on saying "on occasion" and "particular case", making it > > seem like it's such a rarity that it's not worth mentioning. > > > > > > > > Regarding your examples: the rule is quite si

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Timon Gehr
On 06/11/2012 12:28 AM, Mehrdad wrote: Ugh... you keep on saying "on occasion" and "particular case", making it seem like it's such a rarity that it's not worth mentioning. Regarding your examples: the rule is quite simple: - Literals are static by default - If they are to be assigned to a dy

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
Ugh... you keep on saying "on occasion" and "particular case", making it seem like it's such a rarity that it's not worth mentioning. Regarding your examples: the rule is quite simple: - Literals are static by default - If they are to be assigned to a dynamic array, then make them dynamic i

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Jonathan M Davis
On Sunday, June 10, 2012 23:23:57 Mehrdad wrote: > I honestly don't see the POINT of having a "dynamic array > literal". > > What's the point of making the literals dynamic? > > They should all be static, and only converted to dynamic if > necessary from the context. > > But I really don't see t

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Mehrdad
I honestly don't see the POINT of having a "dynamic array literal". What's the point of making the literals dynamic? They should all be static, and only converted to dynamic if necessary from the context. But I really don't see the benefit of allocating them on the heap just because we can.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Artur Skawina
On 06/10/12 19:32, Timon Gehr wrote: > On 06/10/2012 07:00 PM, Artur Skawina wrote: >> On 06/10/12 18:02, Timon Gehr wrote: >>> On 06/10/2012 04:54 PM, Artur Skawina wrote: ... An array literal is a dynamic array with a known constant length that implicitly converts to a static array

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Timon Gehr
On 06/10/2012 07:00 PM, Artur Skawina wrote: On 06/10/12 18:02, Timon Gehr wrote: On 06/10/2012 04:54 PM, Artur Skawina wrote: ... An array literal is a dynamic array with a known constant length that implicitly converts to a static array of the same size and element type. That's a sane definit

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Artur Skawina
On 06/10/12 18:02, Timon Gehr wrote: > On 06/10/2012 04:54 PM, Artur Skawina wrote: >> On 06/10/12 10:47, mta`chrono wrote: >>> Am 10.06.2012 01:02, schrieb Timon Gehr: On 06/10/2012 12:34 AM, Jonathan M Davis wrote: > On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: >> D static arr

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Timon Gehr
On 06/10/2012 04:54 PM, Artur Skawina wrote: On 06/10/12 10:47, mta`chrono wrote: Am 10.06.2012 01:02, schrieb Timon Gehr: On 06/10/2012 12:34 AM, Jonathan M Davis wrote: On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: D static array literals don't perform a costly heap allocation. It is

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread d1rulz
writefln(typeof([1, 2, 3, 4, 5]).stringof) is int[5u] in D1 haha.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread Artur Skawina
On 06/10/12 10:47, mta`chrono wrote: > Am 10.06.2012 01:02, schrieb Timon Gehr: >> On 06/10/2012 12:34 AM, Jonathan M Davis wrote: >>> On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: D static array literals don't perform a costly heap allocation. It is simply a bug in the implementati

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-10 Thread mta`chrono
Am 10.06.2012 01:02, schrieb Timon Gehr: > On 06/10/2012 12:34 AM, Jonathan M Davis wrote: >> On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: >>> D static array literals don't perform a costly heap allocation. It is >>> simply a bug in the implementation. This is not a compelling reason to >>>

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Jonathan M Davis
On Sunday, June 10, 2012 01:02:40 Timon Gehr wrote: > On 06/10/2012 12:34 AM, Jonathan M Davis wrote: > > On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: > >> D static array literals don't perform a costly heap allocation. It is > >> simply a bug in the implementation. This is not a compelling

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Alex Rønne Petersen
On 10-06-2012 01:02, Timon Gehr wrote: On 06/10/2012 12:34 AM, Jonathan M Davis wrote: On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: D static array literals don't perform a costly heap allocation. It is simply a bug in the implementation. This is not a compelling reason to add new syntax.

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Timon Gehr
On 06/10/2012 12:34 AM, Jonathan M Davis wrote: On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: D static array literals don't perform a costly heap allocation. It is simply a bug in the implementation. This is not a compelling reason to add new syntax. D DMD doesn't _have_ static array

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Jonathan M Davis
On Sunday, June 10, 2012 00:15:01 Timon Gehr wrote: > D static array literals don't perform a costly heap allocation. It is > simply a bug in the implementation. This is not a compelling reason to > add new syntax. D doesn't _have_ static array literals. It only has dynamic array literals. int[5]

Re: static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread Timon Gehr
On 06/10/2012 12:05 AM, timotheecour wrote: (apologies for cross-posting here, I feel this is a better place to ask than in my original post where I only received 1 answer that seemed in favor of this: http://d.puremagic.com/issues/show_bug.cgi?id=8008 which was 2 months ago). Please see to the

static array literal syntax request: auto x=[1,2,3]S;

2012-06-09 Thread timotheecour
(apologies for cross-posting here, I feel this is a better place to ask than in my original post where I only received 1 answer that seemed in favor of this: http://d.puremagic.com/issues/show_bug.cgi?id=8008 which was 2 months ago). Please see to the original post above to see the proposal fo