<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<blockquote
cite="mid:CAHJ36ubmWkao4joQFxPn1RwHUhgRUWTB-aznecSaJ0+qnrde2Q@mail.gmail.com"
type="cite"><br>
<div class="gmail_quote">On Tue, Jul 12, 2011 at 4:36 PM,
maurizio.giorda <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:maurizio.giorda@gmail.com">maurizio.giorda@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<u></u>
<div bgcolor="#ffffff" text="#000000"> Hi Matthias, <br>
<br>
... I will play with your example (it is better than all the
words I spent with my looong<br>
description:
<div class="im"><br>
<blockquote type="cite">
<div>
<div>Here is what I meant: </div>
<div><br>
</div>
<div>
<div>#lang racket</div>
<div><br>
</div>
<div>(define-syntax-rule</div>
<div> (mm x)</div>
<div> (lambda (w) (displayln `(,x)) (+ w x)))</div>
</div>
</div>
</blockquote>
</div>
Ok, fine!
<div class="im"><br>
<blockquote type="cite">
<div>
<div>
<div><br>
</div>
<div>(define f </div>
<div> (let ([a 10])</div>
<div> (mm a)))</div>
<div><br>
</div>
<div>(f 42)</div>
</div>
</div>
</blockquote>
</div>
Let me define my function in a inner scope:<br>
<br>
> (let ((othervar 2) <br>
(f (mm (+ 1 othervar))))<br>
> (f 1) <br>
<br>
it should print 4 but it gives the undefined identifier
error.<br>
If I define "othervar" globally (top env) it works (of
course!).<br>
<br>
</div>
</blockquote>
<div><br>
Do you want a let* here instead of let?<br>
</div>
</div>
</blockquote>
Yes Markku,<br>
you (and Matthias) are absolutely right... with let* works.<br>
I did a mistake like a very beginner... <br>
<br>
Nevertheless, now I have to re-formulate my macro.<br>
I started from something like:<br>
<br>
(define-syntax replace<br>
(syntax-rules (replace)<br>
[(replace input ...)<br>
(let* (...let-variables ...)<br>
(eval `(lambda (cntx) <br>
... here unquote either let-variables and other
utility functions...<br>
... maybe reference external variables... <br>
))]))<br>
<br>
What I do is simply to build the lambda code (with quasiquote ...
unquote ...).<br>
The code is huge. It "replace" macro is some sort of compiler that
generates the scheme code<br>
for a new construct in a new language (a chemical language)
implemented on top of racket.<br>
<br>
Since Matthias suggested to avoid the (eval (quasiquote (lambda
...))) approach and replace it<br>
with a (lambda ... (quasiquote ...)), now my work is trying to
redesign my implementation.<br>
<br>
Thank you,<br>
Cheers,<br>
<br>
Maurizio.<br>
<br>
<br>
<div class="moz-signature"><a
href="http://it.linkedin.com/in/giordanomaurizio"> <img
src="cid:part1.08010908.02000409@gmail.com" alt="View Maurizio
Giordano's profile on LinkedIn" width="160" border="0"
height="25"></a><a
href="http://it.linkedin.com/in/giordanomaurizio"> </a></div>
</body>
</html>