Re: Generic array

2011-11-16 Thread Dejan Lekic
RenatoL wrote: ##[3] arr = [0, aa, 2.4]; What can i put instead of ##? In C#, just for example, i can write: object[] ar1 = new object[3]; ar1[0] = 1; ar1[1] = hello; ar1[2] = 'a'; and it works. But in D Object[3] arr0 = [0, aa, 2.4]; and compiler complains In D, the

Re: Generic array

2011-11-16 Thread Jonathan M Davis
On Wednesday, November 16, 2011 08:33:04 Dejan Lekic wrote: RenatoL wrote: ##[3] arr = [0, aa, 2.4]; What can i put instead of ##? In C#, just for example, i can write: object[] ar1 = new object[3]; ar1[0] = 1; ar1[1] = hello; ar1[2] = 'a'; and it works. But in D

Re: Mutable enums

2011-11-16 Thread Steven Schveighoffer
On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/15/2011 04:53 PM, Steven Schveighoffer wrote: Yes, but this is spelled out because copying a static array requires moving data. However, this does *not* require a hidden allocation (even though it does do a hidden

Re: Mutable enums

2011-11-16 Thread Timon Gehr
On 11/16/2011 02:22 PM, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/15/2011 04:53 PM, Steven Schveighoffer wrote: Yes, but this is spelled out because copying a static array requires moving data. However, this does *not* require

Re: Mutable enums

2011-11-16 Thread Timon Gehr
On 11/16/2011 08:26 PM, Timon Gehr wrote: auto a = [new Foo, new Bar, new Qux]; // I want that to work. (It currently does, if that was unclear)

Re: Mutable enums

2011-11-16 Thread Steven Schveighoffer
On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 02:22 PM, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch wrote: Note that this is an explicit allocation: int[] a = [1,2,3]; // just as explicit as a

Re: Mutable enums

2011-11-16 Thread Steven Schveighoffer
On Wed, 16 Nov 2011 15:00:16 -0500, Steven Schveighoffer schvei...@yahoo.com wrote: The one case which is difficult to do is initializing a fixed-size array with a literal that uses runtime data. I suppose we'd need a function that returns a fixed-sized array made of its arguments, and

Re: Mutable enums

2011-11-16 Thread Timon Gehr
On 11/16/2011 09:00 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 02:22 PM, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch wrote: Note that this is an explicit allocation:

Re: Mutable enums

2011-11-16 Thread Simen Kjærås
On Wed, 16 Nov 2011 21:00:16 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 02:22 PM, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch wrote: Note

Re: Mutable enums

2011-11-16 Thread Steven Schveighoffer
On Wed, 16 Nov 2011 16:47:58 -0500, Simen Kjærås simen.kja...@gmail.com wrote: On Wed, 16 Nov 2011 21:00:16 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 02:22 PM, Steven Schveighoffer

Re: Mutable enums

2011-11-16 Thread Steven Schveighoffer
On Wed, 16 Nov 2011 16:16:48 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 09:00 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 02:22 PM, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 13:45:02 -0500, Timon

Re: Mutable enums

2011-11-16 Thread Timon Gehr
On 11/16/2011 10:56 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 16:16:48 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 09:00 PM, Steven Schveighoffer wrote: On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote: On 11/16/2011 02:22 PM, Steven

Re: Mutable enums

2011-11-16 Thread Timon Gehr
On 11/16/2011 11:39 PM, Timon Gehr wrote: I think this is a better solution: void foo2(T: ParameterTypeTuple!foo[0])(T t){foo(t);} Then it is just a matter of applying proper value range propagation for IFTY: void bar(T: short)(T t){...} void main(){ bar(1); // ok } BTW, this already