swarm-support
[Top][All Lists]
Advanced

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

Re: Sharing variables and inline functions


From: Fabio Mascelloni
Subject: Re: Sharing variables and inline functions
Date: Thu, 04 Mar 1999 14:45:21 +0100


Axel von Kamp wrote:

> I've also been thinking about how to efficiently gain read access to instance
> variables without declaring them as @public. My idea (inspired by what
> C++ does) is that, since in Objective C you can still use functions and gcc
> supports inline functions (which is not ANSI standard), to use inline
> functions for access. I have edited the example below to illustrate what I'm
> talking about
>
>
> inline int getShared (ModelSwarm *this);
>
>
>
> inline int getShared (ModelSwarm *this)
> {
>     return self-> shared;
> }
>
>
> int myInt;
> myInt= getShared (modelSwarm);
>

That's right when you want to get a variable that's not a pointer.If  "shared"
was a a pointer, the method would return a reference
to a protected variable,would't it?

>
> This should (?; I'm no compiler expert, so anybody with more technical
> knowledge please comment on this) be as efficient as using a @public instance
> variable without the drawback that @public instance variables can also be
> written to.

> (Furthermore, @public instance variables are not considered to begood style in
> OO languages.)

I don'care much about style when I've only two months to learn Objective-C,Swarm
and make a complex simulation  ;-)

What about implementing a separate generic Objective-C class "CommonClass"  
whose
interface contains all the public members?
The values of these members would be set by the CommonClass instance through
methods defined in the class,and they would be read directly by each other
Swarm-object accessing them with the -->  operator.

>
> -Axel
>
>


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

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