On Tue, Jul 12, 2011 at 4:36 PM, maurizio.giorda <maurizio.gio...@gmail.com> wrote:
Hi Matthias,

... I will play with your example (it is better than all the words I spent with my looong
description:

Here is what I meant: 

#lang racket

(define-syntax-rule
  (mm x)
  (lambda (w) (displayln `(,x)) (+ w x)))
Ok, fine!


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

(f 42)
Let me define my function in a inner scope:

> (let ((othervar 2)
          (f (mm (+ 1 othervar))))
>  (f 1) 

it should print 4 but it gives the undefined identifier error.
If I define "othervar" globally (top env) it works (of course!).


Do you want a let* here instead of let?
Yes Markku,
you (and Matthias) are absolutely right... with let* works.
I did a mistake like a very beginner...

Nevertheless, now I have to re-formulate my macro.
I started from something like:

(define-syntax replace
   (syntax-rules (replace)
     [(replace input ...)
      (let* (...let-variables ...)
        (eval `(lambda (cntx) 
                  ...  here unquote either let-variables and other utility functions...
                  ... maybe reference external variables...   
              ))]))

What I do is simply to build the lambda code (with quasiquote  ... unquote ...).
The code is huge. It "replace" macro is some sort of compiler that generates the scheme code
for a new construct in a new language (a chemical language) implemented on top of racket.

Since Matthias suggested to avoid the (eval (quasiquote (lambda ...))) approach and replace it
with a (lambda ... (quasiquote ...)), now my work is trying to redesign my implementation.

Thank you,
Cheers,

Maurizio.


_________________________________________________
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/users

Reply via email to