home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:3374 comp.lang.clos:766
- Newsgroups: comp.object,comp.lang.clos
- Path: sparky!uunet!munnari.oz.au!metro!graham
- From: graham@maths.su.oz.au (Graham Matthews)
- Subject: Implementation Question
- Message-ID: <graham.715435125@galois>
- Sender: graham@maths.su.oz.au
- Nntp-Posting-Host: galois.maths.su.oz.au
- Organization: School of Mathematics and Statistics, University of Sydney
- Date: Wed, 2 Sep 1992 11:58:45 GMT
- Lines: 42
-
- I was wondering about a small implementation problem I am having.
- Imagine I have two classes A and B defined as follows,
-
- class A
- instance variables a, b, c;
- end class;
-
- class B
- subclass of class A;
- instance variables e, f;
- end class;
-
- (by "instance variable" i mean that an instance of class A will
- have three "fields"/"slots" (pick your terminology!) named a, b and
- c).
-
- Now my problem is as follows. How do OO implentations handle the
- space allocation for an instance of class B? Does an instance of B
- have to have space allocated for all the instance variables in B as
- well as all the instance variables in all the classes of which B is
- a sub-class (in this case class A). I ask this for three reasons :-
-
- a) I have many examples where B is a subclass of A but one rarely
- utilises this feature. All the time is spent computing with instances
- of B as instances of the sub-class B and not as instances of the
- super-class A. So I do not want to allocate space for any instance
- variables (in this case those in class A) which I am rarely if ever
- going to use.
-
- b) I have example code where the representation of B is not the
- same as A. That is mathematically B is a sub-type of A but for
- various reasons the implementation of B does not have any of the
- slots of A.
-
- I can think of one solution using associative arrays, but this must
- be a standard problem with a set of standard solutions.
-
- graham
- --
- Graham Matthews And it's true we are immune
- Pure Math, Uni.Sydney, Oz When fact is fiction and T.V. is reality
- graham@maths.su.oz.au
-