Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!johnson From: johnson@p.cs.uiuc.edu Newsgroups: comp.object Subject: Re: Evaluating "Object-Oriented" Progra Message-ID: <135300024@p.cs.uiuc.edu> Date: 15 Jan 90 01:38:47 GMT References: <638@ajpo.sei.cmu.edu> Lines: 23 Nf-ID: #R:ajpo.sei.cmu.edu:638:p.cs.uiuc.edu:135300024:000:1094 Nf-From: p.cs.uiuc.edu!johnson Jan 13 09:39:00 1990 Markku Sakkinen wrote: >Question: However, isn't it actually bogus that all fundamental things >in _Smalltalk_ are first-class objects? For instance, how do you define >a use a meaningful subclass of SmallInteger, adding at least one >instance variable? SmallIntegers are implemented by a hack (use of a tag bit) so, as far as I know, none of the Smalltalks let you subclass SmallInteger. However, this is not a problem in practice, since it is easy to subclass Integer, and all you have to do is make a new kind of Integer whose value is a SmallInteger and that delegates a few important operations (+,-,/,*,<,=) to its value. Such a subclass will work like a SmallInteger and you can easily add new methods or variables to it without interfering with regular SmallIntegers. This is an extreme example of a general property of inheritance: it is usually a lot cleaner to inherit from abstract classes than from concrete classes. It is quite common for a subclass to need a different data representation, but inheritance brings along the superclass's data representation. Ralph Johnson