Tail-calls (was Re: Equality of Recursive Structures [Was: Closure Compiler in 3.9 ?])

Tony Garnock-Jones tonyg at lshift.net
Sat May 12 14:37:14 UTC 2007


Hi Lukas,

The problem with the examples you've given is that none of them justify
not eliding dead stack frames by themselves.

The usual argument for retaining dead stack frames is to make debugging
easier. The usual arguments against are the safe-for-space property and
to allow the expression of advanced control structures that are
otherwise impossible to express directly.

Lukas Renggli wrote:
> aClass>>add: a with: b
>    b = 0 ifTrue: [ SomeGlobal := thisContext ].
>    ^ self add: a with: b+1

This is the example that comes closest to demonstrating why retaining
dead frames might be interesting: examination of thisContext can tell
you how many times you've tail-recursed.

> aClass>>add: a with: b
>    self become: #zork.
>    ^ self add: a with: b+1
> 
> aClass>>add: a with: b
>    self class removeSelector: #add:with:.
>    ^ self add: a with: b+1

Neither of these are affected at all by removing the no-op frames,
unless I'm missing something.

Regards,
  Tony




More information about the Squeak-dev mailing list