Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!scramble.lm.com!news.math.psu.edu!psuvax1!uwm.edu!reuter.cse.ogi.edu!qiclab.scn.rain.com!gemstone.com!servio!news
From: cohenb@gemstone.com (Bruce Cohen)
Subject: Re: Class Info Repository
In-Reply-To: Robin S Karatra's message of Thu, 21 Mar 1996 09:36:35 -0500
Message-ID: <COHENB.96Mar23131212@topdog.gemstone.com>
Lines: 55
Sender: news@slc.com (USENET News)
Nntp-Posting-Host: topdog
Reply-To: cohenb@gemstone.com
Organization: GemStone Systems, Inc.
References: <9603211436.AA09839@kmglmail.wipsys.soft.net>
Date: 23 Mar 1996 21:12:12 GMT

In article <9603211436.AA09839@kmglmail.wipsys.soft.net> Robin S Karatra <robin@KMGLMAIL.WIPSYS.SOFT.NET> writes:

> 
> We need to keep a repository that will give information about classes
> dynamically. Of course, we can query class objects to get this kind of
> information. But what if we need to store more info about classes than
> what Smalltalk stores? In this case, we will have to monitor class
> creation and modification and update our repository. I want this to be
> done automatically. For example, when a class is created, we should ask
> to enter more details about that class, such as type of attributes.
> 
> Can you give any suggestions on this? I tried subclassing Object and I
> defined a class method 'subclass:instVarNames:classVarNames:poolVarNames'.
> But this doen't work all the time, for example when an instnace
> variable is removed.

Subclassing will only get you so far; when you are interested in
changing the behavior of the whole system, well, you have to *change*
the system, not create variants.  Of course, that's one of the powers of
Smalltalk, that you can modify basic system behavior.

So, pun intended, you probably want to modify Behavior, and/or Class, to
record the information you want.  Changing the metaobjects makes more
sense than changing Object, since it's class information you want to
deal with.  So modify the subclass creation methods to store the
information you are interested in, and add the inquiry methods needed to
get the information back out.  Then, instead of getting the information
by sending 'myObject whenWasYourClassCreated', you would send 'myObject
class whenWereYouCreated' (ignore the whimsical names if serious naming
schemes are important to you ;-).

Here's an example of adding class creation to VisualWorks by modifying
Class>>subclass: instanceVariableNames: classVariableNames: Class>>Class>>poolDictionaries:,
which has been renamed to realSubclass...

subclass: className
	instanceVariableNames: stringOfInstVars
	classVariableNames: stringOfClassVars
	poolDictionaries: stringOfPoolNames

    | subclass |
    subclass := self realSubclass: className
	instanceVariableNames: stringOfInstVars
	classVariableNames: stringOfClassVars
	poolDictionaries: stringOfPoolNames
    subclass timeStamp: Timestamp now. "Setter for new Class instVar timeStamp"
    ^subclass
    

-- 
-----------------------------------------------------------------------------
Bruce Cohen,                               |  email: cohenb@gemstone.com
GemStone Systems, Inc.                     |  phone: (503)690-3602
15400 NW Greenbrier Pkwy, Suite 280        |  fax:   (503)629-8556
Beaverton, OR USA 97006                    |  web:   http://www.gemstone.com
