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!).

> (define othervar 2)
>  (let ((f (mm (+ 1 othervar))))
        (f 1)
it prints 4.

If you ask me why I need to call "mm" with an _expression_, instead of a value... like: (mm (+ 1 othervar))
The answer is: my macro "replace" is a constructor of a function... I would like that this
function could reference external variables (not passed by parameters): if the reference
extern variable is defined (in the current scope) its value is used, otherwise the function
must give the "undefined identifier error".
The function I refer to is a "chemical reaction function": it applies to chemical molecules
(the macro parameters) but it can use reference to external variables to fire or not the
reaction. Example

(replace x y by x if (> x top)) -> #<procedure>

says: replace any pair of two molecules (x and y) with only one of them if
the value of the first is not greater than "top".

Cheers,

Maurizio.

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

Reply via email to