Hi,
This is probably a silly question but I'm having major troubles with define-syntax or syntax-rules.
I used to work with the gambit debian packages version 4.0b20 however it seems the necessary files (syntax-case.scm ...) are missing from the package. So I complied and installed 4.0b22. Now I can load the syntax-case.scm file however it seems I can't get a simple syntax definition to work. Even the simple example from the Gambit-C documentation doesn't work.
Gambit Version 4.0 beta 22
(load "~~syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
(define-syntax unless
(syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console@3.15 -- Ill-formed expression
Unfortunately i couldn't find information on this problem in the documentation or the archives so i'm kinda stuck now. Any help is appreciated.
Thanks, Gabriel
Afficher les réponses par date
According to Marc, it seems that the debian package of gambit-c (which is not an "official" package) has syntax-case included by default for some reason. Therefore, using the debian version, try just not loading syntax-case manually.
Don't forget to clean (apt-get remove packagename --purge) your system of both versions, debian and source before reinstalling the package. Or even better, yet less "debianish", use only the source version. Debian choices are made to fit most of its users expectations, but know the programs less that their implementers.
Tell us if it fixes your problem
By the way, you may also do something with define-macro
(define-macro (unless condition act1 . action) `(if ,condition #f (begin ,act1 ,@action)))
(unless (= 1 3) (pp "phew") (pp "that was close !"))
(pp (unless (= 1 1) (pp "never happens"))) (pp (unless (= 1 2) (pp "whereas ") (pp "this happens") #t))
This should let you define our own syntax if you can't succeed in having syntax-case working (but remember of hygienic or not macros)
Hope it helps,
Adrien
On Fri, Jun 15, 2007 at 05:05:39PM +0200, Gabriel Kronberger wrote :
Hi,
This is probably a silly question but I'm having major troubles with define-syntax or syntax-rules.
I used to work with the gambit debian packages version 4.0b20 however it seems the necessary files (syntax-case.scm ...) are missing from the package. So I complied and installed 4.0b22. Now I can load the syntax-case.scm file however it seems I can't get a simple syntax definition to work. Even the simple example from the Gambit-C documentation doesn't work.
Gambit Version 4.0 beta 22
(load "~~syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
(define-syntax unless
(syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console@3.15 -- Ill-formed expression
Unfortunately i couldn't find information on this problem in the documentation or the archives so i'm kinda stuck now. Any help is appreciated.
Thanks, Gabriel _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On 6/16/07, pierarda@iro.umontreal.ca pierarda@iro.umontreal.ca wrote:
According to Marc, it seems that the debian package of gambit-c (which is not an "official" package) has syntax-case included by default for some reason. Therefore, using the debian version, try just not loading syntax-case manually.
Don't forget to clean (apt-get remove packagename --purge) your system of both versions, debian and source before reinstalling the package. Or even better, yet less "debianish", use only the source version. Debian choices are made to fit most of its users expectations, but know the programs less that their implementers.
Tell us if it fixes your problem
Unfortunately this does not fix my problem. I removed all Gambit-C files from my system
debian:/# apt-get remove gambc --purge debian:/# rm -r /usr/local/Gambit-C
Then i reinstalled the gambc package
debian:/# apt-get install gambc
debian:/# gsi Gambit Version 4.0 beta 20
(define-syntax unless
(syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console)@2.19 -- Ill-formed expression
(load "~~/syntax-case")
*** ERROR IN (console)@5.1 -- No such file or directory (load "~~/syntax-case") 1>
It seems syntax-rules and/or define-syntax is not defined. The file syntax-case.scm is not available. Ok next i removed the debian package again.
debian:/# apt-get remove gambc --purge
And i compiled gambit-c 4.0b22 from the sources:
debian:/home/user/Desktop/gambc-4.0b22# make [...] debian:/home/user/Desktop/gambc-4.0b22# make check [...] ============ ALL TESTS SUCCESSFUL [...] debian:/home/user/Desktop/gambc-4.0b22# make install [...] debian:/home/user/Desktop/gambc-4.0b22# make bootstrap [...] debian:/home/user/Desktop/gambc-4.0b22# export PATH=/usr/local/Gambit-C/current/bin/:$PATH
debian:/home/user/Desktop/gambc-4.0b22# gsi Gambit Version 4.0 beta 22
(load "~~/syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
syntax-rules
*** ERROR IN (console)@2.1 -- Unbound variable: syntax-rules 1> define-syntax *** ERROR IN (console)@3.1 -- Unbound variable: define-syntax 2> (define-syntax unless (syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console)@5.19 -- Ill-formed expression 2>
It seems even though I can load syntax-case.scm, syntax-rules and define-syntax are still not defined. I must be missing something really obvious!
I know that I can use define-macro. I use it in my code now. However I would also like to play around with syntax-rules and according to the documentation it should work the way I tried to use it. So either I'm missing something obvious or the documentation is outdated or syntax-case.scm doesn't work on my debian system.
Any more hints I could try to make syntax-rules work? Thanks, Gabriel
By the way, you may also do something with define-macro
(define-macro (unless condition act1 . action) `(if ,condition #f (begin ,act1 ,@action)))
(unless (= 1 3) (pp "phew") (pp "that was close !"))
(pp (unless (= 1 1) (pp "never happens"))) (pp (unless (= 1 2) (pp "whereas ") (pp "this happens") #t))
This should let you define our own syntax if you can't succeed in having syntax-case working (but remember of hygienic or not macros)
Hope it helps,
Adrien
On Fri, Jun 15, 2007 at 05:05:39PM +0200, Gabriel Kronberger wrote :
Hi,
This is probably a silly question but I'm having major troubles with define-syntax or syntax-rules.
I used to work with the gambit debian packages version 4.0b20 however it seems the necessary files (syntax-case.scm ...) are missing from the package. So I complied and installed 4.0b22. Now I can load the syntax-case.scm file however it seems I can't get a simple syntax definition to work. Even the simple example from the Gambit-C documentation doesn't work.
Gambit Version 4.0 beta 22
(load "~~syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
(define-syntax unless
(syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console@3.15 -- Ill-formed expression
Unfortunately i couldn't find information on this problem in the documentation or the archives so i'm kinda stuck now. Any help is appreciated.
Thanks, Gabriel _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
-- "I am not a Church numeral; I am a free variable!" (The Scheme Underground)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 17-Jun-07, at 7:37 AM, Gabriel Kronberger wrote:
debian:/home/user/Desktop/gambc-4.0b22# gsi Gambit Version 4.0 beta 22
(load "~~/syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
syntax-rules
*** ERROR IN (console)@2.1 -- Unbound variable: syntax-rules 1> define-syntax *** ERROR IN (console)@3.1 -- Unbound variable: define-syntax 2> (define-syntax unless (syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console)@5.19 -- Ill-formed expression 2>
It seems even though I can load syntax-case.scm, syntax-rules and define-syntax are still not defined. I must be missing something really obvious!
I know that I can use define-macro. I use it in my code now. However I would also like to play around with syntax-rules and according to the documentation it should work the way I tried to use it. So either I'm missing something obvious or the documentation is outdated or syntax-case.scm doesn't work on my debian system.
Any more hints I could try to make syntax-rules work? Thanks, Gabriel
I've done exactly the same thing on my MacBook Pro and get this (correct) behavior:
% gsi Gambit Version 4.0 beta 22
(load "~~/syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
syntax-rules
*** ERROR -- invalid syntax syntax-rules
define-syntax
*** ERROR -- invalid syntax define-syntax
(define-syntax unless
(syntax-rules () ((unless test body ...) (if test #f (begin body ...)))))
(unless #f (display "hello\n"))
hello
Something really strange is happening with your installation! Are you sure you are using the official distribution of beta 22?
http://www.iro.umontreal.ca/~gambit/download/gambit/4.0/source/ gambc-4.0b22.tar.gz
Also, could you check the top of the file /usr/local/Gambit-C/4.0b22/ syntax-case.scm ? It should read:
;======================================================================= =======
; File: "syntax-case.scm", Time-stamp: <2007-04-04 10:13:27 feeley>
; Copyright (c) 1998-2007 by Marc Feeley, All Rights Reserved.
; This is version 3.2 .
; This version includes a patch which avoids quoting self-evaluating ; constants. This makes it possible to use some Gambit specific forms ; such as declare, namespace and define-macro.
Also, make sure no "gambcext" and "gambcini" files are being loaded. To avoid loading the gambcini file do
% gsi -f
Marc
On 6/17/07, Marc Feeley feeley@iro.umontreal.ca wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 17-Jun-07, at 7:37 AM, Gabriel Kronberger wrote:
debian:/home/user/Desktop/gambc-4.0b22# gsi Gambit Version 4.0 beta 22
(load "~~/syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
syntax-rules
*** ERROR IN (console)@2.1 -- Unbound variable: syntax-rules 1> define-syntax *** ERROR IN (console)@3.1 -- Unbound variable: define-syntax 2> (define-syntax unless (syntax-rules () ((unless test body ...) (if test #f (begin body ...))))) *** ERROR IN (console)@5.19 -- Ill-formed expression 2>
It seems even though I can load syntax-case.scm, syntax-rules and define-syntax are still not defined. I must be missing something really obvious!
I know that I can use define-macro. I use it in my code now. However I would also like to play around with syntax-rules and according to the documentation it should work the way I tried to use it. So either I'm missing something obvious or the documentation is outdated or syntax-case.scm doesn't work on my debian system.
Any more hints I could try to make syntax-rules work? Thanks, Gabriel
I've done exactly the same thing on my MacBook Pro and get this (correct) behavior:
% gsi Gambit Version 4.0 beta 22
(load "~~/syntax-case")
"/usr/local/Gambit-C/4.0b22/syntax-case.scm"
syntax-rules
*** ERROR -- invalid syntax syntax-rules
define-syntax
*** ERROR -- invalid syntax define-syntax
(define-syntax unless
(syntax-rules () ((unless test body ...) (if test #f (begin body ...)))))
(unless #f (display "hello\n"))
hello
Something really strange is happening with your installation! Are you sure you are using the official distribution of beta 22?
http://www.iro.umontreal.ca/~gambit/download/gambit/4.0/source/ gambc-4.0b22.tar.gz
Also, could you check the top of the file /usr/local/Gambit-C/4.0b22/ syntax-case.scm ? It should read:
;=======================================================================
; File: "syntax-case.scm", Time-stamp: <2007-04-04 10:13:27 feeley>
; Copyright (c) 1998-2007 by Marc Feeley, All Rights Reserved.
; This is version 3.2 .
; This version includes a patch which avoids quoting self-evaluating ; constants. This makes it possible to use some Gambit specific forms ; such as declare, namespace and define-macro.
Also, make sure no "gambcext" and "gambcini" files are being loaded. To avoid loading the gambcini file do
% gsi -f
Marc
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin)
iD8DBQFGdSsF//V9Zc2T/v4RAqedAJoD3Vx9ZU7HQeqqSEbMY71kTydxRwCZARFu bYxdY7qjfWok0F/mMZpt3Rc= =SkFr -----END PGP SIGNATURE-----
Hi Marc,
It works like a charm now! Unfortunately I don't have a good explanation for the problems. I guess what happened was that I installed a version from an unclean build with some files still lying around from an unsuccessful --enable-gcc-opts building attempt (not enough RAM).
I checked the syntax-case file of the old installation and it matched your version. Then I redownloaded gambc-4.0b22.tar.gz and configured, built and installed it. Now I can load syntax-case and there are no apparent problems with syntax-rules.
Thanks for the help, Gabriel