RFC-24 macros question

Umberto Nicoletti umberto.nicoletti at GMAIL.COM
Tue Jul 10 02:27:02 EDT 2007


I think that names are extremely important and picking great
meaningful names is a valuable gift in programming.
It's ok for me to change the macros, but I would retain the IS verb
which means expect a boolean result:

#define MS_REFCNT_DECR_IS_NOT_ZERO(obj) (MS_REFCNT_DECR(obj))>0
#define MS_REFCNT_DECR_IS_ZERO(obj) (MS_REFCNT_DECR(obj))<=0

Will you do the change?
Umberto

On 7/9/07, Daniel Morissette <dmorissette at mapgears.com> wrote:
> Umberto,
>
> As part of your work on RFC-24 you defined the following two macros:
>
> #define MS_REFCNT_IS_NOT_ZERO(obj) (MS_REFCNT_DECR(obj))>0
> #define MS_REFCNT_IS_ZERO(obj) (MS_REFCNT_DECR(obj))<=0
>
> I find the name of the macros confusing when we encounter them in if
> statements in the code because it is not obvious that they include an
> implicit decrement of the refcount. At first I thought the code calling
> them was just testing whether refcount was zero but I didn't realize
> until I looked at the macros that they also decremented it.
>
> Would it not be better if the macros were named in a way that made it
> clear that they will also decrement refcount, perhaps:
>
> #define MS_REFCNT_DECR_NOT_ZERO(obj) (MS_REFCNT_DECR(obj))>0
> #define MS_REFCNT_DECR_ZERO(obj) (MS_REFCNT_DECR(obj))<=0
>
> What do you think?
>
> Daniel
> --
> Daniel Morissette
> http://www.mapgears.com/
>



More information about the mapserver-dev mailing list