[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

macros expanding into definitions



> I'm still not sure that I want to screw around with internal defines,
> but if we must, I might actually like to see internal defines start a
> new scope and have previous assignments refer to outer scopes. Doesn't
> ML have something like this (at least at top-level).

I think this approach would presents a new problem. Consider the following:

(define (fib x)
  (define (fib-even x) 
    (if (= x 0)
        0
        (+ (fib-even (- x 2))
           (fib-odd (- x 1)))))
  (define (fib-odd x)
    (if (= x 1)
        1
        (+ (fib-even (- x 1))
           (fib-odd (- x 2)))))
  ((if (even? x) fib-even fib-odd) x))

(fib 3)

This would be an error in fib-even because fib-odd would not be bound.
The notion of wrapping a valid top level program in a let still wouldn't
work for normal cases when (n) procedures are mutually recursive. 

lou