Re: Array Copying syntax

2016-09-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/16 2:48 PM, Steven Schveighoffer wrote: On 9/16/16 2:28 PM, Antonio Corbi wrote: Way clearer (at least for me) with your patch! Hah, except it's actually wrong :) s = a compiles. Updated, should be good now. -Steve

Re: Array Copying syntax

2016-09-16 Thread Ali Çehreli via Digitalmars-d-learn
On 09/16/2016 10:11 AM, Adam D. Ruppe wrote: On Friday, 16 September 2016 at 17:03:20 UTC, Antonio Corbi wrote: Is it safe to use or do I have to use the proposed 's[] = t;' or 's[] = t[]' ? That works for all arrays. `s = t` for dynamically sized arrays (aka slices) just sets the references t

Re: Array Copying syntax

2016-09-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/16 2:28 PM, Antonio Corbi wrote: On Friday, 16 September 2016 at 18:12:22 UTC, Steven Schveighoffer wrote: On 9/16/16 2:03 PM, Antonio Corbi wrote: Hi Jonathan! Probably this entry in https://dlang.org/spec/arrays.html#usage confused me a bit. int[3] s; s = ...; // error, sinc

Re: Array Copying syntax

2016-09-16 Thread Antonio Corbi via Digitalmars-d-learn
On Friday, 16 September 2016 at 18:12:22 UTC, Steven Schveighoffer wrote: On 9/16/16 2:03 PM, Antonio Corbi wrote: Hi Jonathan! Probably this entry in https://dlang.org/spec/arrays.html#usage confused me a bit. int[3] s; s = ...; // error, since s is a compiled in static /

Re: Array Copying syntax

2016-09-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/16/16 2:03 PM, Antonio Corbi wrote: Hi Jonathan! Probably this entry in https://dlang.org/spec/arrays.html#usage confused me a bit. int[3] s; s = ...; // error, since s is a compiled in static // reference to an array. Thanks for your help! Antonio Yeah, that's bad.

Re: Array Copying syntax

2016-09-16 Thread Antonio Corbi via Digitalmars-d-learn
On Friday, 16 September 2016 at 17:55:59 UTC, Jonathan M Davis wrote: On Friday, September 16, 2016 17:22:41 Antonio Corbi via Digitalmars-d-learn wrote: Shouldn't it be mentioned then in the docs that this works for statically sized arrays and that in that case it copies contents? Well, I co

Re: Array Copying syntax

2016-09-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 16, 2016 17:22:41 Antonio Corbi via Digitalmars-d-learn wrote: > Shouldn't it be mentioned then in the docs that this works for > statically sized arrays and that in that case it copies contents? Well, I confess that I don't know why you would ever have thought that s = t;

Re: Array Copying syntax

2016-09-16 Thread Antonio Corbi via Digitalmars-d-learn
On Friday, 16 September 2016 at 17:11:54 UTC, Adam D. Ruppe wrote: On Friday, 16 September 2016 at 17:03:20 UTC, Antonio Corbi wrote: Is it safe to use or do I have to use the proposed 's[] = t;' or 's[] = t[]' ? That works for all arrays. `s = t` for dynamically sized arrays (aka slices) jus

Re: Array Copying syntax

2016-09-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 16 September 2016 at 17:03:20 UTC, Antonio Corbi wrote: Is it safe to use or do I have to use the proposed 's[] = t;' or 's[] = t[]' ? That works for all arrays. `s = t` for dynamically sized arrays (aka slices) just sets the references to the same, but for your statically sized ar

Array Copying syntax

2016-09-16 Thread Antonio Corbi via Digitalmars-d-learn
Hi! I was just playing with array initialization and copying and discovered that this syntax works as expected but it is not referenced under https://dlang.org/spec/arrays.html#array-copying: -8><- int[3] s; int[3] t; s = t; -8><- Is it safe to use or do I have to use the pr