[racket] Metaprogramming with scheme

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Jun 22 03:34:50 EDT 2010

On Jun 22, Valeriya Pudova wrote:
> 
> (define (foo a b)
>    (for-each (lambda (e) (display e)(newline)) 
> (continuation-mark-set->context (current-continuation-marks))))
> 
> (define (bar a b)
>    (foo a b))
> 
> (bar 1 2)
> [...]
> 
> Interesting. There are no the function bar in the backtrace. Why?

Because it's no longer there -- the tail call replaces it.  Try to run
this in DrRacket (exactly as is, don't reindent):

                   (define (foo3 x)
                     (/ x "1"))

  (define (foo2 x)
    (foo3 x))
                   (define (foo1 x)
                     (list (foo2 x)))
  (define (foo0 x)
    (car (foo1 x)))

           (+ 1 (foo0 3))

and you'll see that the arrows skip `foo2'.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.