[gambit-list] macro-expansion bug (?)

dev null doonboggle at gmail.com
Tue Feb 22 10:42:53 EST 2005


I see.  I figured that I was probably confused.

Thanks!

Ben



On Tue, 22 Feb 2005 10:34:59 -0500, Marc Feeley <feeley at iro.umontreal.ca> wrote:

> Your code is not legal R5RS Scheme.  In R5RS Scheme you can't use in
> the evaluation of the value part of a "define" a variable "define"d at
> the same level.  I.e. this is illegal:
> 
> (define (f x)
> 
>   (define n 10)
>   (define m (+ n 1))
> 
>   ...)
> 
> You should use let* instead like this:
> 
> (define-macro (build-funcs)
>   (let* ((any
>           '(list? number? string?))
>          (funcnames
>           `((is-string string?)
>             (is-number number?)
>             (is-list list?)
>             (is-any ,any))))
> 
>     (define (build desc)
>       (let ((name (car desc))
>             (tests (if (list? (cadr desc))
>                        (cadr desc)
>                        (cdr desc))))
>         `(define ,name
>            (lambda (o)
>              (or ,@(map (lambda (x)
>                           (list x 'o))
>                         tests))))))
> 
>     `(begin ,@(map build funcnames))))
> 
> Note that your original code will work in Gambit 3.0, but in version
> 4.0 the implementation was changed to detect these violations of the
> R5RS Scheme standard.
> 
> Marc
> 
>


More information about the Gambit-list mailing list