discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Setter Gettor method style


From: Martin Häcker
Subject: Re: Setter Gettor method style
Date: Sun, 4 Aug 2002 06:06:51 +0200

Hi there,

after reading up on the Macros that are defined in NSObject.h I've got some questions.
-- All the Macros I read there are designed in a way like this:
#define DESTROY(object)         ({ \
  [...]
})

Now I am not totally sure about this, but I've learnt (listening to some kernel developers) that one should always write multi line Macros in some slightly different way like this:

#define DESTROY(object)         do { \
  if (object) \
    [...]
} while(0)

(http://www.rtems.com/rtems/maillistArchives/rtems-users/2001/august/msg00056.html)

I see that both work, so is there one that has some advantages? Or is it just personal preference what to use?

-- I find macros there for the retain and release (sorry, I tried to search the archive for a recent discussions but couldn't get the Geocrawler to give me a search field.. please forgive my dumbness). Why? I see that they are defined to just do nothing if Garbage-Collection is enabled, but wouldn't it be much better to do this inside the actual retain/release/autorelease methods to have a more coherent syntax? Or is it necessary for optimization to put these macros in here?

-- I found macros for ASSIGN and TEST_RELEASE and so forth. Why not go a step further and also build macros that give you the full set of Setter/Getter methods?

That's all for now and I hope I didn't stress you too much!

Thanks for reading so much. :)
cu Martin
--
dont.wanna.tell
[ot]coder - hehe



reply via email to

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