discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Private methods?


From: Andreas Heppel
Subject: Re: Private methods?
Date: Mon, 26 Apr 2004 09:42:48 +0200

On 2004-04-25 22:23:30 +0200 John Baxter <john@ebaxters.net> wrote:

Why would a language have private data members but then make all methods "setters" public?... does this not then make the data public? I am a bit confused by this.
No, the data actually stays private. No other piece of code can access it _directly_. That is the key word here. On a private/protected ivar you cannot do something like 'myobject->data' as would be possible if data was public. As soon as you implement a setter method, it is your explicit wish to provide a method for the outside world to access this ivar, because for class internal use you would not need it.

The statement that all methods not declared in the interface are 'private' is more a matter of convention. As the compiler (and the programmer, of course) doesn't see those methods it will give a warning, that this method is _possibly_ not meant for public usage. But you will not be prevented from doing so.


Andreas

--
Mail: aheppel at web dot de
Home: http://www.andreasheppel.de
PGP Key: http://www.andreasheppel.de/download/andreash.asc

Check out Burn.app - the CD burning frontend for GNUstep
http://gsburn.sourceforge.net





reply via email to

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