Re: Array initialization quiz

2011-11-30 Thread Andrej Mitrovic
On 11/30/11, Steven Schveighoffer wrote: > I remember at one point there was someone who had actual code that > resulted in a loop for ubytes, or was trying to figure out how to foreach > over all possible ubyte values. Instant flashback, I think it was this: http://www.digitalmars.com/d/archives

Re: Array initialization quiz

2011-11-30 Thread Ali Çehreli
On 11/30/2011 10:17 AM, Xinok wrote: > On 11/30/2011 11:46 AM, Steven Schveighoffer wrote: >> >> foreach(_i; ubyte.min..ubyte.max + 1){ >> ubyte i = cast(ubyte)_i; >> } >> >> But my point was, foreach over a range gives me all the elements in a >> range, regardless of how the underlying loop is co

Re: Array initialization quiz

2011-11-30 Thread Xinok
On 11/30/2011 11:46 AM, Steven Schveighoffer wrote: On Wed, 30 Nov 2011 10:54:11 -0500, Xinok wrote: On 11/30/2011 7:50 AM, Steven Schveighoffer wrote: On Tue, 29 Nov 2011 15:06:11 -0500, Jonathan M Davis wrote: The type of the index should be irrelavent to the underlying loop mechanism. N

Re: Array initialization quiz

2011-11-30 Thread Steven Schveighoffer
On Wed, 30 Nov 2011 10:54:11 -0500, Xinok wrote: On 11/30/2011 7:50 AM, Steven Schveighoffer wrote: On Tue, 29 Nov 2011 15:06:11 -0500, Jonathan M Davis wrote: The type of the index should be irrelavent to the underlying loop mechanism. Note that the issue is really that foreach(T i, val; a

Re: Array initialization quiz

2011-11-30 Thread Xinok
On 11/30/2011 7:50 AM, Steven Schveighoffer wrote: On Tue, 29 Nov 2011 15:06:11 -0500, Jonathan M Davis wrote: The type of the index should be irrelavent to the underlying loop mechanism. Note that the issue is really that foreach(T i, val; arr) {...} translates to for(T i = 0; i < arr.length;

Re: Array initialization quiz

2011-11-30 Thread Steven Schveighoffer
On Tue, 29 Nov 2011 15:06:11 -0500, Jonathan M Davis wrote: On Tuesday, November 29, 2011 20:42:59 Marco Leise wrote: Am 29.11.2011, 20:41 Uhr, schrieb Marco Leise : > Am 29.11.2011, 14:53 Uhr, schrieb bearophile : >> deadalnix: >>> No it has nothing to do with this bug. >> >> I tend to a

Re: Array initialization quiz

2011-11-29 Thread Jonathan M Davis
On Tuesday, November 29, 2011 20:42:59 Marco Leise wrote: > Am 29.11.2011, 20:41 Uhr, schrieb Marco Leise : > > Am 29.11.2011, 14:53 Uhr, schrieb bearophile : > >> deadalnix: > >>> No it has nothing to do with this bug. > >> > >> I tend to agree. > >> > >>> But actually, this exemple should > >>>

Re: Array initialization quiz

2011-11-29 Thread Marco Leise
Am 29.11.2011, 20:41 Uhr, schrieb Marco Leise : Am 29.11.2011, 14:53 Uhr, schrieb bearophile : deadalnix: No it has nothing to do with this bug. I tend to agree. But actually, this exemple should generate a warning at least, or being illegal eventually. I'd like that code to loop on a

Re: Array initialization quiz

2011-11-29 Thread Marco Leise
Am 29.11.2011, 14:53 Uhr, schrieb bearophile : deadalnix: No it has nothing to do with this bug. I tend to agree. But actually, this exemple should generate a warning at least, or being illegal eventually. I'd like that code to loop on all array 256 items once, and then stop :-) Bye, b

Re: Array initialization quiz

2011-11-29 Thread bearophile
deadalnix: > No it has nothing to do with this bug. I tend to agree. > But actually, this exemple should > generate a warning at least, or being illegal eventually. I'd like that code to loop on all array 256 items once, and then stop :-) Bye, bearophile

Re: Array initialization quiz

2011-11-29 Thread Andrej Mitrovic
I meant that in a sarcastic way. :)

Re: Array initialization quiz

2011-11-29 Thread deadalnix
Le 29/11/2011 04:11, Andrej Mitrovic a écrit : On 11/29/11, bearophile wrote: Do you know why the compiler doesn't ask you for a cast, and why the run does that? Because foreach is broken? http://d.puremagic.com/issues/show_bug.cgi?id=4510 No it has nothing to do with this bug. But actually

Re: Array initialization quiz

2011-11-28 Thread Andrej Mitrovic
On 11/29/11, bearophile wrote: > Do you know why the compiler doesn't ask you for a cast, and why the run > does that? Because foreach is broken? http://d.puremagic.com/issues/show_bug.cgi?id=4510

Re: Array initialization quiz

2011-11-28 Thread bearophile
Andrej Mitrovic: > Err no? Running after compilation goes into an infinite loop on 2.056. Silly, this is a quiz, you need to try to answer without compiling it first :-) Do you know why the compiler doesn't ask you for a cast, and why the run does that? Bye, bearophile

Re: Array initialization quiz

2011-11-28 Thread Andrej Mitrovic
Err no? Running after compilation goes into an infinite loop on 2.056.

Re: Array initialization quiz

2011-11-28 Thread bearophile
Andrej Mitrovic: > I get an infinite loop. :s In your brain, really? Is that dangerous? Bye, bearophile

Re: Array initialization quiz

2011-11-28 Thread Andrej Mitrovic
I get an infinite loop. :s