Re: [GD-General] Variables scope
Brought to you by:
vexxed72
|
From: Jorrit T. <Jor...@uz...> - 2004-02-04 14:26:11
|
CAVEY GERARD wrote:
>>Kristoffer Grönlund wrote:
>>
>>
>>
>>>The way I've worked around this in the past has been by redefining for as
>>>follows:
>>>#define for if (false) {} else for
>>>
>>>Yes, it's a hideously ugly hack, but so is the problem in the first place.
>>>I've never had any problems because of it.
>>>
>>>
>>>
>>>
>>Hmm... sounds like an ugly solution for something that is more simply
>>solved by just
>>declaring the loop counter outside the for.
>>
>>
>
>Hi
>As Mr Aravelo(pyrostudios) told me out of list
>it can also be written
>#define for if (1) for
>a bit simpler ...
>
>
Yes but that can give bad results. For example:
if (a > b)
for (...)
else
...
With your version of 'for' the 'else' branch will never execute since it
will be
the 'else' for the 'if (1)'. With the previous version of 'for' that
problem is not there
because there is already an 'else' branch given in the 'for' define.
Greetings,
|