hi all
i try to define the following syntax: (define-syntax when (syntax-rules () ((_ test stm1 stm2 ...) (if test (begin stm1 stm2 ...)))))
but getting the following error with the bracket pair after syntax-rules highlighted (in emacs): *** ERROR IN (stdin)@2.17 -- Ill-formed expression
this occurs on both version 4.4.4 and 4.5.1.
i try on chicken scheme and it works fine.
this is basic stuff but i can't get around it, have searched on the net but nothing came out.
am i missing something? or?
thanks
antonitio
Afficher les réponses par date
Gambit-C 4.5.1 here, I can't seem to make any syntax-rule work either. MD5 (/usr/local/lib/gambit-c/syntax-case.scm) = e53a1b858553730c86c34d7923aadb59
Either a bad syntax-case.scm was provided in the archive, either it is now incompatible and nobody realized it before you. Either I forgot how to write a trivial define-syntax. Since most users of gambit seem to prefer define-macro, you may have discovered the bug first.
P!
2009/8/25 antonitio antonitio@gmail.com:
but getting the following error with the bracket pair after syntax-rules highlighted (in emacs): *** ERROR IN (stdin)@2.17 -- Ill-formed expression this occurs on both version 4.4.4 and 4.5.1. am i missing something? or?
after reading the doc on define-macro and define-syntax, i realized that i need to load the syntax-case first, and when i did that and execute the define-syntax again it works now!
i didn't know that there's a gambit expansion define-macro (thanks adrien for pointing this out :-)
why using define-macro instead of define-syntax since define-syntax is define in the standard (hence more portable) even though some implementations also have define-macro? is there any advantage of using define-macro? less code? common-lisp-like?
thanks,
antonitio
On Tue, Aug 25, 2009 at 1:54 PM, Adrien Piérard pierarda@iro.umontreal.cawrote:
Gambit-C 4.5.1 here, I can't seem to make any syntax-rule work either. MD5 (/usr/local/lib/gambit-c/syntax-case.scm) = e53a1b858553730c86c34d7923aadb59
Either a bad syntax-case.scm was provided in the archive, either it is now incompatible and nobody realized it before you. Either I forgot how to write a trivial define-syntax. Since most users of gambit seem to prefer define-macro, you may have discovered the bug first.
P!
2009/8/25 antonitio antonitio@gmail.com:
but getting the following error with the bracket pair after syntax-rules highlighted (in emacs): *** ERROR IN (stdin)@2.17 -- Ill-formed expression this occurs on both version 4.4.4 and 4.5.1. am i missing something? or?
-- Français, English, 日本語, 한국어
2009/8/25 antonitio antonitio@gmail.com:
it works now!
Great! Though, to remind you, having (load "~~lib/define-syntax") in the file that uses it will not work (because it mixes runtime and macroexpansion) You may have to do gsi -e '(load "~~lib/define-syntax")' your-file-with-macros.scm
i didn't know that there's a gambit expansion define-macro (thanks adrien for pointing this out :-)
Since you *will* have bugs if this is your first time with define-macro, I also remind you that you can do gsc -expansion file-with-define-macro-s-used.scm to see what the expanded code looks like.
why using define-macro instead of define-syntax since define-syntax is define in the standard (hence more portable) even though some implementations also have define-macro? is there any advantage of using define-macro? less code? common-lisp-like?
Well, there is much to debate about this, but you first have to compare syntax-rules (which is hygienic and simple) and syntax-case (which I happen to not know at all for I never felt the need to use it). Define-macro allows me to *easily* share state between different macro expansions, to write macros that write macros (that write macros…), and to mask/rebind symbols that are defined in the context calling the macro. I am pretty sure you can do that with syntax-case too, but as I said, I am ill at ease with it.
I let those who use syntax-case make the case (sic) clearer and enlighten both of us.
P!
it seems to me to be like the case of global versus local variable for passing parameters...
thanks for your help P!
On Tue, Aug 25, 2009 at 3:58 PM, Adrien Piérard pierarda@iro.umontreal.cawrote:
2009/8/25 antonitio antonitio@gmail.com:
it works now!
Great! Though, to remind you, having (load "~~lib/define-syntax") in the file that uses it will not work (because it mixes runtime and macroexpansion) You may have to do gsi -e '(load "~~lib/define-syntax")' your-file-with-macros.scm
i didn't know that there's a gambit expansion define-macro (thanks adrien for pointing this out :-)
Since you *will* have bugs if this is your first time with define-macro, I also remind you that you can do gsc -expansion file-with-define-macro-s-used.scm to see what the expanded code looks like.
why using define-macro instead of define-syntax since define-syntax is define in the standard (hence more portable) even though some implementations also have define-macro? is there any advantage of using define-macro? less code? common-lisp-like?
Well, there is much to debate about this, but you first have to compare syntax-rules (which is hygienic and simple) and syntax-case (which I happen to not know at all for I never felt the need to use it). Define-macro allows me to *easily* share state between different macro expansions, to write macros that write macros (that write macros…), and to mask/rebind symbols that are defined in the context calling the macro. I am pretty sure you can do that with syntax-case too, but as I said, I am ill at ease with it.
I let those who use syntax-case make the case (sic) clearer and enlighten both of us.
P!
-- Français, English, 日本語, 한국어