Pop Quiz what is wrong with this code?

Danni Coy danni.coy at gmail.com
Sat Jun 20 16:00:40 UTC 2020


On Sun, Jun 21, 2020 at 1:15 AM rikki cattermole via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 21/06/2020 3:08 AM, Danni Coy wrote:
> > ...
> > foreach (y, ref row; offsetMap)
> > {
> >     auto run = 0;
> >      auto nPixels = 0;
> >      foreach (x; 0..size.x)
> >      {
> >           immutable SDL_FPair offset  = { center.x - x, y - center.y };
> > ...
> >
> > and why does it violate the principle of making the right thing the
> > easy thing to do?
> >
>
> oo oo, is it that you didn't want x and y to be of type size_t?
more specifically I didn't want them to be unsigned
I am adapting the code from C++ code,
coming from other Algol syntax languages. That one is a real
gotcha. I tried explicitly making x and y ints and I got a depreciation warning.

> And why are you initializing run and nPixels manually?
the value there so the compiler can figure out the type (auto)


More information about the Digitalmars-d mailing list