Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!godot.cc.duq.edu!newsgate.duke.edu!news.mathworks.com!fu-berlin.de!news.belwue.de!news.uni-kl.de!rz.uni-karlsruhe.de!blackbush.xlink.net!ins.net!heeg.de!gustav!hmm
From: hmm@gustav (Hans-Martin Mosner)
Subject: Re: Tail recursion ???
Message-ID: <DwDquu.JFJ@heeg.de>
Sender: uucp@heeg.de
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
X-Newsreader: TIN [version 1.2 PL2]
References: <4uvjlg$i0b@goanna.cs.rmit.edu.au>
Date: Mon, 19 Aug 1996 10:08:53 GMT
Lines: 39

Mark Rohan Hulme (mrh@yallara.cs.rmit.EDU.AU) wrote:
: Does a typical smalltalk `compiler' change recursive calls
: into interation in the same way that a lisp would ? 

: Thanks Mark

No, because in general, a message send to self is not
necessarily bound to the same method. Consider this example:

(B is a subclass of A)

!A methodsFor: 'example'!

foo
   self doTheAThing.
   self shouldContinue
      ifTrue: [self foo]! !

!B methodsFor: 'example'!

foo
   self doTheBThing.
   super foo! !

For class A, this could be converted into:
 [self doTheAThing. self shouldContinue] whileTrue: [].
But for class B, it would be:
 [self doTheBThing. self doTheAThing. self shouldContinue] whileTrue: [].

The compiler has not enough information to do the right thing, because
a message send is not a function call.

Hans-Martin

--
+--- Hans-Martin Mosner -------- Senior Smalltalk Guru ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
