home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / object / 3374 < prev    next >
Encoding:
Internet Message Format  |  1992-09-02  |  2.0 KB

  1. Xref: sparky comp.object:3374 comp.lang.clos:766
  2. Newsgroups: comp.object,comp.lang.clos
  3. Path: sparky!uunet!munnari.oz.au!metro!graham
  4. From: graham@maths.su.oz.au (Graham Matthews)
  5. Subject: Implementation Question
  6. Message-ID: <graham.715435125@galois>
  7. Sender: graham@maths.su.oz.au
  8. Nntp-Posting-Host: galois.maths.su.oz.au
  9. Organization: School of Mathematics and Statistics, University of Sydney
  10. Date: Wed, 2 Sep 1992 11:58:45 GMT
  11. Lines: 42
  12.  
  13. I was wondering about a small implementation problem I am having.
  14. Imagine I have two classes A and B defined as follows,
  15.  
  16.     class A
  17.         instance variables a, b, c;
  18.     end class;
  19.  
  20.     class B
  21.         subclass of class A;
  22.         instance variables e, f;
  23.     end class;
  24.  
  25. (by "instance variable" i mean that an instance of class A will
  26. have three "fields"/"slots" (pick your terminology!) named a, b and
  27. c).
  28.  
  29. Now my problem is as follows. How do OO implentations handle the 
  30. space allocation for an instance of class B? Does an instance of B
  31. have to have space allocated for all the instance variables in B as 
  32. well as all the instance variables in all the classes of which B is 
  33. a sub-class (in this case class A). I ask this for three reasons :-
  34.  
  35. a) I have many examples where B is a subclass of A but one rarely
  36. utilises this feature. All the time is spent computing with instances
  37. of B as instances of the sub-class B and not as instances of the 
  38. super-class A. So I do not want to allocate space for any instance 
  39. variables (in this case those in class A) which I am rarely if ever 
  40. going to use.
  41.  
  42. b) I have example code where the representation of B is not the
  43. same as A. That is mathematically B is a sub-type of A but for
  44. various reasons the implementation of B does not have any of the 
  45. slots of A.
  46.  
  47. I can think of one solution using associative arrays, but this must
  48. be a standard problem with a set of standard solutions.
  49.  
  50. graham
  51. --
  52. Graham Matthews                 And it's true we are immune
  53. Pure Math, Uni.Sydney, Oz       When fact is fiction and T.V. is reality
  54. graham@maths.su.oz.au
  55.