any news on const/invariant?
Derek Parnell
derek at nomail.afraid.org
Mon Nov 26 23:28:08 PST 2007
On Tue, 27 Nov 2007 06:54:40 +0000, Janice Caron wrote:
> 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.
I'm sorry I'm not getting my request out clear enough.
I *know* that at run time the GammaAdjust routine cannot effectively change
the pointer. But that is not what I'm saying.
I would like the compiler to tell me at /compile/ time that I've
incorrectly attempted to change a pointer that has been designed to remain
unchanged. I would like to avoid waiting for this to only become apparent
at /run/ time.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
27/11/2007 6:24:56 PM
More information about the Digitalmars-d
mailing list