any news on const/invariant?

Janice Caron caron800 at googlemail.com
Mon Nov 26 22:54:40 PST 2007


On 11/27/07, Derek Parnell <derek at nomail.afraid.org> wrote:
> On Mon, 26 Nov 2007 21:24:13 -0800, Walter Bright wrote:
>
> > I'm not sure why one would need protection against changing the bitmap
> > pointer. GammaAdjust should just take a byte[], not a ref byte[].
>
>  byte[] bitmap;
>  bitmap = LoadBitMapFromFile("worldroadmap.bmp");
>  GammaAdjust(bitmap, 0.20);
>  Render(device, bitmap);
>
> If the 'GammaAdjust' routine changed the pointer then 'Render' routine
> would not display the adjusted bitmap.

The GammaAdjust routine /cannot/ change the pointer, because it is
passed in by value, not by reference.

I guess it could change its own local copy of the pointer, but that
would just be a bug local to the function.



More information about the Digitalmars-d mailing list