Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!orion.oac.uci.edu!ucivax!rmyers From: rmyers@ics.uci.edu (Richard E. Myers) Newsgroups: comp.lang.objective-c Subject: Re: Requirements for Class Variables for Objective-C Keywords: class variables Message-ID: <270A66D0.14263@ics.uci.edu> Date: 3 Oct 90 22:31:43 GMT References: <5638@stpstn.UUCP> Reply-To: rmyers@ics.uci.edu (Richard E. Myers) Organization: UC Irvine Department of ICS Lines: 52 Though I'm just a novice in Objective-C I have run across a case where class variables would simplify things. In answer to your first two questions, I believe class variables would be useful and that case one would be the better system. >** 1 -- each subclass has its own copy of its parent's class variables > > 2 -- all subclasses share a single copy of their parent's class variables I think at run time each subclass should be thought of as distinct from its parent and thus have it's own variables. A programmer shouldn't have to worry about changes made to the class variables of a parent class or sibling class effecting its own class variables. Unless someone can give examples why this ability would be needed then to minimize side effects system one seems adequate. A hypothetical use that makes me favor class variables is as follows: Suppose the first instantiation of a class "PriorityQ" puts its id into a class variable call "defaultQ". Subsequent calls to the class "PriorityQ" using the method "+newORdefault" would then return the id contained in "defaultQ" or a new id if the "defaultQ" variable is nil. If (using another method) the variable "defaultQ" was changed then any new invocations of the "+newORdefault" method would return the new id in the class variable "defaultQ". What bothers me about this example is that (I think) NeXT has produced a similar effect in their "Conductor" class (which can be found within the MusicKit). If class variables don't exist in Objective C then I'm not sure how they did this. I hope I haven't over looked something due to my limited experience with Objective C. Cheers, -- Richard ------------------------------------------------------------------------------- "Programs were devised whose `thinking' was to human thinking as a slinky flipping end over end down a staircase is to human locomotion." -- D.R. Hoffstadter ------------------------------------------------------------------------------- Richard Myers / 6 Exeter / Irvine, CA 92715 / 714-854-4410 / rmyers@ics.uci.edu -- ------------------------------------------------------------------------------- "Programs were devised whose `thinking' was to human thinking as a slinky flipping end over end down a staircase is to human locomotion." -- D.R. Hoffstadter