Array initialization quiz
Jonathan M Davis
jmdavisProg at gmx.com
Tue Nov 29 12:06:11 PST 2011
On Tuesday, November 29, 2011 20:42:59 Marco Leise wrote:
> Am 29.11.2011, 20:41 Uhr, schrieb Marco Leise <Marco.Leise at gmx.de>:
> > Am 29.11.2011, 14:53 Uhr, schrieb bearophile <bearophileHUGS at lycos.com>:
> >> 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
> >
> > Is it evil if I propose that 'i' should always be size_t and nothing
> > else?
>
> Yes, because you can iterate over -10..10 as well -.-
I would argue that i should always be size_t if it's an index. So,
foreach(i; -10 .. 10) {}
would be valid, but
int[] arr;
foreach(byte i, val; arr) {}
wouldn't be.
- Jonathn M Davis
More information about the Digitalmars-d-learn
mailing list