gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problems compiling NSAnimation.m


From: Nicola Pero
Subject: Re: problems compiling NSAnimation.m
Date: Thu, 10 May 2007 17:09:12 +0200


This looks pretty bad, not only because it doesn't compile with GCC
2.95, but also because that variable defined in the middle of
nowhere is very ugly ... unclear
scope (what happens if you have two _NSANIMATION_LOCK in
sequence ?  is the same variable being used or different
variables ?) ...

This macro is used as a macro : to repeat again and again the same
piece of code. It only has to be used in this class. If you have two
_NSANIMATION_LOCK then you have made an error : would you code two
[NSThread -lock] in sequence ?

What I mean is that I find the code

/* some code here */

 int c = 0;

 /* do something with c */

 int c = 0;

 /* do something with c */

very confusing, because when the second declaration of c is reached, you need to
be a C standard lawyer to know what happens ;-)

Ie, will it keep the same value that it had ? will the second declaration shadow the
first one ?  will the second assignment to c happen or not ?

What about adding a macro

_NSANIMATION_SETUP

that defines your local variable (and does nothing else) - and that you put at the beginning
of every method -, and then have

_NSANIMATION_LOCK

that only checks/assigns the variable ?

ie, the equivalent of

#define _NSANIMATION_SETUP \
int c = 0;

#define _NSANIMATION_LOCK \
/* do something with c */

Thanks




reply via email to

[Prev in Thread] Current Thread [Next in Thread]