swarm-support
[Top][All Lists]
Advanced

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

Re: What class are you?


From: Scott Christley
Subject: Re: What class are you?
Date: Wed, 24 Sep 1997 10:09:57 -0700

At 11:34 AM 9/24/97 -0400, Dwight Wilson wrote:

>What's the difference between these functions?
>Class objc_get_class(const char *name)
>and
>Class objc_lookup_class(const char *name)

They are practically the same except that objc_get_class will trigger an
error if the class does not exist; while objc_lookup_class just returns NULL.

objc_get_class is used by the compiler when it generates code for calling a
method, so if the class does not exist in the runtime the program will abort
with an error.  User programs generally use objc_lookup_class so that they
can just check if a class without the program aborting.

>And, what does this intriguingly named function do?
>Class class_pose_as(Class imposter, Class superclass)

Intriguing indeed.  It essentially allows a class to replace its superclass
in the runtime.  This is used extensively in the GNUstep GUI library where
there is a front-end library and a back-end library.  The front-end library
is general for all graphical systems while the back-end library is specific
to a graphical system, like Windows or X.  The back-end library poses as the
front-end library classes; thus essentially customizing the front-end
classes with the back-end specific functionality.

The interesting thing about -poseAs: is that the "imposter" can still call
the superclass' methods like normal through the super variable.  The main
limitation is that the imposter class *must* be the same size; i.e. it
cannot add any additional instance variables.

cheers
Scott


                  ==================================
   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]