Re: Fixed size array initialization

2018-02-11 Thread rumbu via Digitalmars-d-learn
On Sunday, 11 February 2018 at 14:06:32 UTC, rjframe wrote: On Sat, 10 Feb 2018 10:55:30 +, rumbu wrote: If you separate initialization to a static this, you'll get a compile error: ``` immutable uint256[78] pow10_256; static this() { // Error: mismatched array lengths, 78 and 2

Re: Fixed size array initialization

2018-02-11 Thread rjframe via Digitalmars-d-learn
On Sat, 10 Feb 2018 10:55:30 +, rumbu wrote: > I know that according to language spec > (https://dlang.org/spec/arrays.html#static-init-static) you can skip > declaring all your elements in a fixed size array. > > I'm just recovering from a bug which took me one day to discover because > of t

Re: Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
On Sunday, 11 February 2018 at 01:26:59 UTC, psychoticRabbit wrote: On Sunday, 11 February 2018 at 01:13:00 UTC, psychoticRabbit wrote: Well, in C.. I can do: int arr[2] = { [0]=10, [1]=20 }; I cannot work out how to do that in D yet (anyone know??) Oh. just worked it out after reading thi

Re: Fixed size array initialization

2018-02-10 Thread psychoticRabbit via Digitalmars-d-learn
On Sunday, 11 February 2018 at 01:13:00 UTC, psychoticRabbit wrote: Well, in C.. I can do: int arr[2] = { [0]=10, [1]=20 }; I cannot work out how to do that in D yet (anyone know??) Oh. just worked it out after reading this thread ;-) int[2] arr = [ 0:10, 1:20 ];

Re: Fixed size array initialization

2018-02-10 Thread psychoticRabbit via Digitalmars-d-learn
On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I have a large static initialized array, let's say int[155], and I forgot to declare the last element: int[155] myarray = [ a, b, c, ... //forgot to declare the 155th element ]; Well, in C.. I can do: int arr[2] = { [0]

Re: Fixed size array initialization

2018-02-10 Thread Seb via Digitalmars-d-learn
On Saturday, 10 February 2018 at 15:54:03 UTC, rumbu wrote: On Saturday, 10 February 2018 at 14:55:49 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote: In this case, it there any way to be sure that I declared all the elements I intended? Obviously, without count

Re: Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
On Saturday, 10 February 2018 at 14:55:49 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote: In this case, it there any way to be sure that I declared all the elements I intended? Obviously, without counting them by hand. At the level of the library use a templa

Re: Fixed size array initialization

2018-02-10 Thread b2.temp--- via Digitalmars-d-learn
On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote: On Saturday, 10 February 2018 at 12:28:16 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip decl

Re: Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
On Saturday, 10 February 2018 at 12:28:16 UTC, b2.temp wrote: On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip declaring all your elements in a fixed size array. I'm just rec

Re: Fixed size array initialization

2018-02-10 Thread Kagamin via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=481#c40

Re: Fixed size array initialization

2018-02-10 Thread b2.temp--- via Digitalmars-d-learn
On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote: I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip declaring all your elements in a fixed size array. I'm just recovering from a bug which took me one day to discover because o

Fixed size array initialization

2018-02-10 Thread rumbu via Digitalmars-d-learn
I know that according to language spec (https://dlang.org/spec/arrays.html#static-init-static) you can skip declaring all your elements in a fixed size array. I'm just recovering from a bug which took me one day to discover because of this. I have a large static initialized array, let's say