Demystifying "most Smalltalk ¹ s don't directly support multiple inheritance"
Lic. Edgar J. De Cleene
edgardec2001 at yahoo.com.ar
Thu Jun 22 23:14:20 UTC 2006
Klaus D. Witzel puso en su mail :
> List,
>
> haven't you heard that Smalltalk and Squeak do not directly support
> multiple inheritance, time and again? But that Perl, Python and Ruby do
> (to some extent)?
> - http://www.google.com/search?q=python+ruby+multiple+inheritance
>
> Well, that is not the case for Smalltalk since the time that VMs are
> implemented by using the specs of the Blue Book.
>
> I have attached a small .st file which demonstrates that the *unchanged*
> VM *must* support multiple inheritance (for message sends), or else it
> won't work properly. It's a matter of view on what the VM does for you :-D
>
> With the exception of support code for exceptions [pun intended] the
> attached examples work on VMs which implement the super send from the Blue
> Book.
>
> The first example demonstrates that multiple inheritance works; in this
> example it is also checked that the requesting method qualifies (that the
> instances qualify is checked at fileIn time).
>
> The second example does a message tally and shows that there is less than
> 50% overhead when possible walkbacks are guarded at every multiple
> inheritance message send.
>
> The third example employs the existing method cache of the VM (the
> original Squeak VM) for multiple inheritance message sends and thus
> minimizes the overhead to less than 5% (and the demo is written in .st
> code :-)
>
> Again, this all exists *unchanged* for decades. It only had to be brought
> to the surface?
>
> -------
>
> I would be very interested to see if my examples run on other platforms
> and VMs, please post your experience. Thank you.
>
> It'd be equally interesting if the approach had been used before.
>
> /Klaus
> ?
>
DoIt: " MessageTally spyOn: [ | aCupWith |
aCupWith := CaffeeWithMilk newLatteMacchiato.
10000 timesRepeat: [aCupWith veryMuchSugar]] "
Here I got on Mac
1267 tallies, 1273 msec.
**Tree**
99.8% {1270ms} CaffeeWithMilk>>veryMuchSugar
47.0% {598ms} CaffeeWithMilk>>DoIt
|46.7% {594ms} ProcessorScheduler>>nextReadyProcess
| 22.7% {289ms} LinkedList>>isEmpty
| 22.6% {288ms} Array(SequenceableCollection)>>reverseDo:
26.8% {341ms} CaffeeWithMilk(Object)>>doesNotUnderstand:
|12.2% {155ms} MessageNotUnderstood(Exception)>>signal
| |11.8% {150ms} MethodContext(ContextPart)>>handleSignal:
| | 7.5% {95ms} BlockContext>>valueWithPossibleArgs:
|11.5% {146ms} MessageNotUnderstood>>message:
22.3% {284ms} CaffeeWithMilk(SuperclassX)>>internalSwitchSenderToParent:
|17.7% {225ms} UndefinedObject(Object)>>->
| |16.0% {204ms} Association>>key:value:
|2.7% {34ms} CompiledMethod>>numLiterals
3.1% {39ms} BlockContext>>onDNU:do:
**Leaves**
22.7% {289ms} LinkedList>>isEmpty
22.6% {288ms} Array(SequenceableCollection)>>reverseDo:
16.0% {204ms} Association>>key:value:
11.5% {146ms} MessageNotUnderstood>>message:
9.0% {115ms} BlockContext>>valueWithPossibleArgs:
**Memory**
old +0 bytes
young -25,012 bytes
used -25,012 bytes
free +25,012 bytes
**GCs**
full 0 totalling 0ms (0.0% uptime)
incr 550 totalling 356ms (28.0% uptime), avg 1.0ms
tenures 0
root table 0 overflows
But your code deserve more deep study, and I thanks for it.
Edgar
___________________________________________________________
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
http://correo.yahoo.com.ar
More information about the Squeak-dev
mailing list
|