Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!mel.dit.csiro.au!yarra!bacchus!matt From: matt@bacchus.esa.oz (Matthew Atterbury) Newsgroups: comp.object Subject: Re: inheritance and `type loss' Message-ID: <683@bacchus.esa.oz> Date: 13 Jul 90 00:08:25 GMT References: <1130012@gore.com> <1990Jul11.184517.16505@swbatl.sbc.com> Organization: none Lines: 53 Reply-To: In article <1990Jul11.184517.16505@swbatl.sbc.com> gilstrap@swbatl.UUCP (Brian Gilstrap - UCI - 5-3929) writes: > >I could easily see a language where the default was > > convert the Roman to an Integer no matter if it's first or second > (least common denominator) Why stop at Integer? Assuming the Smalltalk hierarchy, why not convert it to a Number, then to an Object? Applying this reasoning would lead to the result of all operations being of type Object ie. a TYPELESS language! Or are you suggesting full expression analysis to see what the most general class is? >OR > convert the Integer to an Roman no matter if it's first or second > (I guess you could call this "specialization of results") Similarly, why stop at Roman? What if there is a subclass of Roman - then all Integers and Romans would be converted to it, and if you subclassed that one later, all your earlier operations would be reconverted. What if Integer has a number of subclasses - which one? Or, again, are you suggesting full expression analysis to see what the most specific class is? >Just because C++ approaches things the way described above doesn't mean it >has to be that way. Smalltalk works like this also. If you are suggesting expression analysis, what if you get two classes that are NOT in very close subtrees of the class hierarchy? Do you then say that the most general form is (probably) Object so the result is converted to Object? And what is the most specific form? Basically, I can see how you could argue for your suggestion given the very simple example of Integer and Roman, but in the context of a class hierarchy, it seems unworkable. The expression: "1 + 2" says (sort of); expression evaluator: hello object of type integer of value 1. I have here an object of type integer with value 2. will you please perform the '+' operator with it, WHATEVER THAT MEANS TO YOU (coz *I* don't know), and tell me the result? integer class: OK. here's the result. (BTW, it's an object of type integer with value 3). In smalltalk (and all "real" OO languages IMHO), even integer operations like '+' are left to the "target" object to perform - they are NOT evaluated by some global omniscient 'expression evaluator'. If Integer decided that the result of adding a Roman to itself ought to be a Roman, it could do the conversion itself - NOTE that this decision is up to Integer, NOT anyone else. Well, this *was* going to be a short reply. Sorry for rambling on & on & on ... -- ------------------------------------------------------------------------------- Matt Atterbury [matt@bacchus.esa.oz.au] Expert Solutions Australia, Melbourne UUCP: ...!uunet!munnari!matt@bacchus.esa.oz.au "klaatu barada nikto" ARPA: matt%bacchus.esa.oz.AU@uunet.UU.NET "life? don't talk to me about life!"