Re: array questions

2009-01-11 Thread bearophile
yes: > is it possible to make a dynamic array less dynamic? > int[][] array; > array[0].length = 10; //has to be set at runtime > writefln(array[1].length); // writes also 10 > Because I now have to loop through the whole array to check for correct size. If you are using normal D dynamic arrays y

Re: container class sample on Tango mainpage can not compile

2009-01-11 Thread Sam Hu
Moritz Warning Wrote: > On Wed, 07 Jan 2009 19:47:57 -0500, Sam Hu wrote: > > > Morning, > > > > Anybody can help? > > > > Regards, > > Sam > > try this: > > auto nameSet=new TreeBag!(char[])(null, (char[] first,char[] second) { > return icompare(first,second); > } > );

Re: using a typedefed variable with library classes

2009-01-11 Thread Charles Hixson
bearophile wrote: Bill Baxter: The first time I tried to use it my thought was to do typedef Exception MyException; To create a different exception type. That doesn't work so I kinda just said, eh whatever, this typedef stuff doesn't work yet. You are right, typedef was invented before cla

Re: container class sample on Tango mainpage can not compile

2009-01-11 Thread Sam Hu
Moritz Warning Wrote: > On Wed, 07 Jan 2009 19:47:57 -0500, Sam Hu wrote: > > > Morning, > > > > Anybody can help? > > > > Regards, > > Sam > > try this: > > auto nameSet=new TreeBag!(char[])(null, (char[] first,char[] second) { > return icompare(first,second); > } > );

Re: array questions

2009-01-11 Thread Daniel Keep
yes wrote: [snip] also, can this be done? int size; size = 10; //runtime void function( int[size][] array){} No, static arrays are static, i.e. compile time. I meant it to be an dynamic array argument, but that the function wouldn't need to check the size of all the elements itself. Dynam

Re: array questions

2009-01-11 Thread yes
> > > Hello again > > > > is it possible to make a dynamic array less dynamic? > > > > int[][] array; > > > > array[0].length = 10; //has to be set at runtime > > Um, if that's your code, everything should crash at this point (or throw > in debug mode): array is null, that is, empty, so there

Re: array questions

2009-01-11 Thread Sergey Gromov
Sun, 11 Jan 2009 17:17:54 -0500, yes wrote: > Hello again > > is it possible to make a dynamic array less dynamic? > > int[][] array; > > array[0].length = 10; //has to be set at runtime Um, if that's your code, everything should crash at this point (or throw in debug mode): array is null, tha

array questions

2009-01-11 Thread yes
Hello again is it possible to make a dynamic array less dynamic? int[][] array; array[0].length = 10; //has to be set at runtime writefln(array[1].length); // writes also 10 Because I now have to loop through the whole array to check for correct size. also, can this be done? int size; size =

Re: using a typedefed variable with library classes

2009-01-11 Thread bearophile
Bill Baxter: > The first time I tried to use it my thought was to do > typedef Exception MyException; > To create a different exception type. That doesn't work so I kinda > just said, eh whatever, this typedef stuff doesn't work yet. You are right, typedef was invented before classes and OOP,

Re: Foreach problem

2009-01-11 Thread Tim M
On Sun, 11 Jan 2009 21:39:55 +1300, Denis Koroskin <2kor...@gmail.com> wrote: On Sun, 11 Jan 2009 11:04:38 +0300, Tim M wrote: On Sun, 11 Jan 2009 20:31:51 +1300, Denis Koroskin <2kor...@gmail.com> wrote: Yep that probibly is a slight bug. What I would like to know is why cant I do fo

Re: Foreach problem

2009-01-11 Thread Denis Koroskin
On Sun, 11 Jan 2009 11:04:38 +0300, Tim M wrote: On Sun, 11 Jan 2009 20:31:51 +1300, Denis Koroskin <2kor...@gmail.com> wrote: Yep that probibly is a slight bug. What I would like to know is why cant I do foreach with primitive types like I can with objects. You can use foreach to itera

Re: Foreach problem

2009-01-11 Thread Tim M
On Sun, 11 Jan 2009 20:31:51 +1300, Denis Koroskin <2kor...@gmail.com> wrote: Yep that probibly is a slight bug. What I would like to know is why cant I do foreach with primitive types like I can with objects. You can use foreach to iterate over arrays and tuples, if that's what you mean