<html>
<body>
<font size=3><br>
Never mind, I figured it out. The macro should have been:<br><br>
(define-syntax m4<br>
(lambda (x)<br>
(syntax-case x ()<br>
<x-tab> </x-tab><x-tab>
</x-tab> ((_ v)<br>
<x-tab> </x-tab><x-tab>
</x-tab>
(with-syntax ((name (datum->syntax-object (syntax v)
(string->symbol (string-append (symbol->string
(syntax-object->datum (syntax v))) ":g")))))<br>
<x-tab> </x-tab><x-tab>
</x-tab><x-tab>
</x-tab>
(syntax (begin<br>
<x-tab> </x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab> (define name
'())<br>
<x-tab> </x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab> (define v
'()))))))))<br><br>
I figured it out by using Chez Scheme. It gave me a meaningful
message<br>
with the wrong macro. MzScheme lets it run and hints that it's
right.<br><br>
I can't hardly imagine making it any more complicated. The
simplest<br>
things are made rocket science with define-syntax and friends.
Lisp<br>
macros may not be perfect but normal people (those who don't devote<br>
their life to understanding the intricacies of syntax-case) can use<br>
and understand it. Syntax-case is killing scheme.<br><br>
Blake McBride<br><br>
<br><br>
At 09:06 AM 9/9/2006, Blake McBride wrote:<br><br>
<blockquote type=cite class=cite cite="">Greetings,<br><br>
I am attempting to create a macro using define-syntax, syntax-case
and<br>
with-syntax under MzScheme 352. I believe my macro definition
is<br>
correct but it just doesn't work under MzScheme. The reason I
believe<br>
my macro definition is correct is because when I cause the macro to<br>
quote it's output (to prevent evaluation) it returns the correct<br>
expression. When I try the expression outside the macro system
it<br>
works.<br><br>
The following example and corresponding macro are simplified
versions<br>
of what I am actually doing but does demonstrate the problem.<br>
Here is the example:<br><br>
Input is:<br><br>
(m4 gen)<br><br>
Expected code to be executes is:<br><br>
(begin<br>
(define gen:g '())<br>
(define gen '()))<br><br>
So, I should end up with two variables being defined. The
macro<br>
generates the correct code, but when it is run gen gets defined but<br>
gen:g does not. If I execute the above code manually, it
works. Why<br>
doesn't it work through the macro?<br><br>
The macro is:<br><br>
(define-syntax m4<br>
(lambda (x)<br>
(syntax-case x ()<br>
<x-tab> </x-tab><x-tab>
</x-tab>((_ v)<br>
<x-tab> </x-tab><x-tab>
</x-tab>
(with-syntax ((name (string->symbol (string-append (symbol->string
(syntax-object->datum (syntax v))) ":g"))))<br>
<x-tab> </x-tab><x-tab>
</x-tab><x-tab>
</x-tab>
(syntax (begin<br>
<x-tab> </x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab>(define name
'())<br>
<x-tab> </x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab><x-tab>
</x-tab>(define v
'()))))))))<br><br>
Thanks.<br>
Blake McBride<br>
</font></blockquote></body>
</html>