[racket] help: how to make eval see local bindings?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Jul 12 09:04:03 EDT 2011

On Jul 12, 2011, at 6:41 AM, Maurizio Giordano wrote:

> Hi Matthias, hi schemers,
> 2011/7/11 Matthias Felleisen <matthias at ccs.neu.edu>
> Now I don't understand at all why you want to use eval in the macro.
> If the right-hand side just returned the lambda that you have there,
> it would automatically capture the variables in the context of the
> gama rule.
> Have you tried just returning the lambda as is from the macro?
> I tried but it doesn't work! Here you find a sample of what you suggest:
> ---------------
> (define-syntax mymacro
>   (syntax-rules (prova)
>     [(mymacro input ...)
>      (lambda (z) (list input ...) (+ z extern-var))]))
> > (let* ((extern-var 2) (f (mymacro x y))) (f 1))
> reference to undefined identifier: extern-var

Here is what I meant: 

#lang racket

  (mm x)
  (lambda (w) (displayln `(,x)) (+ w x)))

(define f 
  (let ([a 10])
    (mm a)))

(f 42)
More later -- Matthias

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110712/b291d042/attachment.html>

Posted on the users mailing list.