[racket] Again on bindings visibility in eval

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Thu Jul 14 08:53:06 EDT 2011

On Jul 14, 2011, at 7:56 AM, Maurizio Giordano wrote:

> About optimization... in my case the main optimization is:
> 1) My macro has to generate a function which has to perform some
> recursive tasks 
> (for example, it has to do a recursive pattern matching on a set of
> elements)
> 2) Instead of generating a recursive function, I generate one very long
> piece of code that expand (I say "inline") all the (potential) recursion
> point.

And how is that an optimization?  What are you gaining by making the code much longer?  If your function was "tail-recursive" (i.e. the result of the recursive call is returned as the result of the calling function, without any further processing), Scheme will already optimize it to take constant stack space (effectively replacing the recursive call, at the machine level, with some assignments and a "goto").  If it wasn't, it's very difficult to see how to inline it -- as I presume you've already discovered.


Stephen Bloch
sbloch at adelphi.edu




Posted on the users mailing list.