Re: Dynamic Array Garbage collection

2009-03-12 Thread bearophile
Jarrett Billingsley: > Wrong types. Right, I am sorry, thank you for spotting it. There's the moderate need for a different kind of cast, for collections (arrays). At the moment you can do: import d.func: map, putr, array, xcast; import std.conv: toInt; import d.templates: ArrayType1; void some

Re: Dynamic Array Garbage collection

2009-03-12 Thread Jarrett Billingsley
On Thu, Mar 12, 2009 at 8:09 AM, bearophile wrote: > wolftousen wrote: >> some_function([ x[0], x[1], x[2], x[3] ]); > > That may also be written: > some_function(x[0 .. 4]); Wrong types.

Re: Dynamic Array Garbage collection

2009-03-12 Thread bearophile
wolftousen wrote: > some_function([ x[0], x[1], x[2], x[3] ]); That may also be written: some_function(x[0 .. 4]); Bye, bearophile

Re: Dynamic Array Garbage collection

2009-03-12 Thread Robert Fraser
wolftousen wrote: I have a function defined as: some_function(int[] array) { ... }; //this function does not ever modify values of array When I call this function (once every program cycle) from an object using an array of type short: //member variable in an object short[] x = new short[4];

Re: Dynamic Array Garbage collection

2009-02-24 Thread grauzone
Jarrett Billingsley wrote: On Tue, Feb 24, 2009 at 10:42 PM, Daniel Keep wrote: You missed the array literal. I saw that, but thought that it would be a short[] literal since it's usually the type of the first argument. Odd, it works. And properly too. Could it be because of integer promo

Re: Dynamic Array Garbage collection

2009-02-24 Thread Jarrett Billingsley
On Tue, Feb 24, 2009 at 10:42 PM, Daniel Keep wrote: >> >> You missed the array literal. > > I saw that, but thought that it would be a short[] literal since it's > usually the type of the first argument. Odd, it works. And properly too. I give up on trying to figure out what the compiler does

Re: Dynamic Array Garbage collection

2009-02-24 Thread Daniel Keep
Jarrett Billingsley wrote: > On Tue, Feb 24, 2009 at 6:45 PM, Daniel Keep > wrote: > >> Maybe it's because I just woke up, but I can't see how that code could >> compile anyway, since you can't pass a short[] to a function expecting >> an int[]. > > You missed the array literal. I saw that,

Re: Dynamic Array Garbage collection

2009-02-24 Thread Jarrett Billingsley
On Tue, Feb 24, 2009 at 6:45 PM, Daniel Keep wrote: >  Maybe it's because I just woke up, but I can't see how that code could > compile anyway, since you can't pass a short[] to a function expecting > an int[]. You missed the array literal.

Re: Dynamic Array Garbage collection

2009-02-24 Thread Daniel Keep
wolftousen wrote: > I have a function defined as: > > some_function(int[] array) { ... }; //this function does not ever modify > values of array > > When I call this function (once every program cycle) from an object using an > array of type short: > > //member variable in an object > short

Dynamic Array Garbage collection

2009-02-24 Thread wolftousen
I have a function defined as: some_function(int[] array) { ... }; //this function does not ever modify values of array When I call this function (once every program cycle) from an object using an array of type short: //member variable in an object short[] x = new short[4]; //object calls thi