Re: Variables scope

Jorrit Tyberghein <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <[email protected]>
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,




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.