Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.
This is the code in test.scm
(define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error: *** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit" /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' test.o: In function `___setup_mod': test.c:(.text+0xa): undefined reference to `___G__20_test' test.o: In function `___init_mod': test.c:(.text+0x26): undefined reference to `___G__20_test' test.o: In function `___H__20_test': test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x214): undefined reference to `___G_x' test.c:(.text+0x24d): undefined reference to `___G_x' test.c:(.text+0x3a6): undefined reference to `___G_x' test.c:(.text+0x450): undefined reference to `___G_x' test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error' test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error' test.o: In function `____20_test': test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_' test.c:(.text+0xd46): undefined reference to `___S_any' test.c:(.text+0xd62): undefined reference to `___S_body' test.c:(.text+0xd70): undefined reference to `___S_condition' test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any' test.c:(.text+0xd9a): undefined reference to `___S_global' test.c:(.text+0xdc4): undefined reference to `___S_loop' test.c:(.text+0xdd2): undefined reference to `___S_ribcage' test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object' test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage' test.c:(.text+0xe34): undefined reference to `___S_x' collect2: error: ld returned 1 exit status
I tried compiling with the interactive mode using (compile-file-to-target "test.scm") (quit) gambitc -exe test.c and it compiles well, but when I try to run the exe I get: *** ERROR IN | test| -- Operator is not a PROCEDURE (#!unbound '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated! (I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)
Afficher les réponses par date
Try manually loading the syntax-case library in test.scm before you use it. With: (load "~~/lib/syntax-case")
On Friday, July 29, 2016 8:34 AM, ochi n ochi12@hotmail.com wrote:
<!--#yiv2151594006 P {margin-top:0;margin-bottom:0;}-->Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.This is the code in test.scm (define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error: *** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit" /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' test.o: In function `___setup_mod': test.c:(.text+0xa): undefined reference to `___G__20_test' test.o: In function `___init_mod': test.c:(.text+0x26): undefined reference to `___G__20_test' test.o: In function `___H__20_test': test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x214): undefined reference to `___G_x' test.c:(.text+0x24d): undefined reference to `___G_x' test.c:(.text+0x3a6): undefined reference to `___G_x' test.c:(.text+0x450): undefined reference to `___G_x' test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error' test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error' test.o: In function `____20_test': test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_' test.c:(.text+0xd46): undefined reference to `___S_any' test.c:(.text+0xd62): undefined reference to `___S_body' test.c:(.text+0xd70): undefined reference to `___S_condition' test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any' test.c:(.text+0xd9a): undefined reference to `___S_global' test.c:(.text+0xdc4): undefined reference to `___S_loop' test.c:(.text+0xdd2): undefined reference to `___S_ribcage' test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object' test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage' test.c:(.text+0xe34): undefined reference to `___S_x' collect2: error: ld returned 1 exit status I tried compiling with the interactive mode using (compile-file-to-target "test.scm") (quit) gambitc -exe test.c and it compiles well, but when I try to run the exe I get: *** ERROR IN | test| -- Operator is not a PROCEDURE (#!unbound '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated! (I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
I did try adding each one of these: (load "~~lib/syntax-case") (load "~~/lib/syntax-case") (include "~~lib/syntax-case.scm") at the beginning of the file, but I keep getting:
*** ERROR IN "/home/octavio/test.scm"@5.17 -- Ill-formed expression
Where line 5 is:
(syntax-rules ()
I have no idea why this is happening, gambit supports macros and this macros is supposed to be legal. Don't know if it helps, but I'm using the code from this tutorial http://www.willdonnelly.net/blog/scheme-syntax-rules/
Thanks for your time!
________________________________ From: Bob Coleman bobcolem@yahoo.com Sent: Friday, July 29, 2016 11:22 AM To: ochi n; gambit-list@iro.umontreal.ca Subject: Re: [gambit-list] Error compiling macros
Try manually loading the syntax-case library in test.scm before you use it. With:
(load "~~/lib/syntax-case")
On Friday, July 29, 2016 8:34 AM, ochi n ochi12@hotmail.com wrote:
Hi all, I'm trying to compile a simple program using macros but for some reason it won't work. This is the code in test.scm
(define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error: *** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit" /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' test.o: In function `___setup_mod': test.c:(.text+0xa): undefined reference to `___G__20_test' test.o: In function `___init_mod': test.c:(.text+0x26): undefined reference to `___G__20_test' test.o: In function `___H__20_test': test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x214): undefined reference to `___G_x' test.c:(.text+0x24d): undefined reference to `___G_x' test.c:(.text+0x3a6): undefined reference to `___G_x' test.c:(.text+0x450): undefined reference to `___G_x' test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error' test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error' test.o: In function `____20_test': test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_' test.c:(.text+0xd46): undefined reference to `___S_any' test.c:(.text+0xd62): undefined reference to `___S_body' test.c:(.text+0xd70): undefined reference to `___S_condition' test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any' test.c:(.text+0xd9a): undefined reference to `___S_global' test.c:(.text+0xdc4): undefined reference to `___S_loop' test.c:(.text+0xdd2): undefined reference to `___S_ribcage' test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object' test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage' test.c:(.text+0xe34): undefined reference to `___S_x' collect2: error: ld returned 1 exit status
I tried compiling with the interactive mode using (compile-file-to-target "test.scm") (quit) gambitc -exe test.c and it compiles well, but when I try to run the exe I get: *** ERROR IN | test| -- Operator is not a PROCEDURE (#!unbound '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated! (I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.camailto:Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
I have no problems running this in the repl. However, I am getting the same issue when using the -exe flag. I believe the syntax-case file needs to be linked into the exe, but I haven't had any luck with that either. I tried linking syntax-case with the source and using gcc to generate the exe per the manual: bob@ubuntulaptop:~/home/bob/tmp$ gsc -:s -c gambit-syntax-test.scmbob@ubuntulaptop:~/home/bob/tmp$ gsc -o syntax-case.c -c /usr/local/Gambit-C/current/lib/syntax-case.scmbob@ubuntulaptop:~/home/bob/tmp$ gsc -link gambit-syntax-test.c syntax-case.cbob@ubuntulaptop:~/home/bob/tmp$ gsc -obj gambit-syntax-test.c syntax-case.c syntax-case_.cgambit-syntax-test.c:syntax-case.c:syntax-case_.c:bob@ubuntulaptop:~/home/bob/tmp$ gcc gambit-syntax-test.o syntax-case.o syntax-case_.o -lgambc -lm -ldl -lutilbob@ubuntulaptop:~/home/bob/tmp$ ./a.out*** ERROR IN | gambit-syntax-test| -- Operator is not a PROCEDURE(#!unbound2 '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)bob@ubuntulaptop:~/home/bob/tmp$
;;;; file: gambit-syntax-test.scm(define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f))))) (define x 0)(while (< x 5) (set! x (+ x 1)) (print x))
On Friday, July 29, 2016 10:57 AM, ochi n ochi12@hotmail.com wrote:
#yiv1090503675 #yiv1090503675 -- P {margin-top:0;margin-bottom:0;}#yiv1090503675 I did try adding each one of these: (load "~~lib/syntax-case") (load "~~/lib/syntax-case") (include "~~lib/syntax-case.scm") at the beginning of the file, but I keep getting: *** ERROR IN "/home/octavio/test.scm"@5.17 -- Ill-formed expression Where line 5 is:
(syntax-rules () I have no idea why this is happening, gambit supports macros and this macros is supposed to be legal. Don't know if it helps, but I'm using the code from this tutorialhttp://www.willdonnelly.net/blog/scheme-syntax-rules/Thanks for your time!
From: Bob Coleman bobcolem@yahoo.com Sent: Friday, July 29, 2016 11:22 AM To: ochi n; gambit-list@iro.umontreal.ca Subject: Re: [gambit-list] Error compiling macros Try manually loading the syntax-case library in test.scm before you use it. With: (load "~~/lib/syntax-case")
On Friday, July 29, 2016 8:34 AM, ochi n ochi12@hotmail.com wrote:
Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.This is the code in test.scm (define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error: *** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit" /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' test.o: In function `___setup_mod': test.c:(.text+0xa): undefined reference to `___G__20_test' test.o: In function `___init_mod': test.c:(.text+0x26): undefined reference to `___G__20_test' test.o: In function `___H__20_test': test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x214): undefined reference to `___G_x' test.c:(.text+0x24d): undefined reference to `___G_x' test.c:(.text+0x3a6): undefined reference to `___G_x' test.c:(.text+0x450): undefined reference to `___G_x' test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error' test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error' test.o: In function `____20_test': test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_' test.c:(.text+0xd46): undefined reference to `___S_any' test.c:(.text+0xd62): undefined reference to `___S_body' test.c:(.text+0xd70): undefined reference to `___S_condition' test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any' test.c:(.text+0xd9a): undefined reference to `___S_global' test.c:(.text+0xdc4): undefined reference to `___S_loop' test.c:(.text+0xdd2): undefined reference to `___S_ribcage' test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object' test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage' test.c:(.text+0xe34): undefined reference to `___S_x' collect2: error: ld returned 1 exit status I tried compiling with the interactive mode using (compile-file-to-target "test.scm") (quit) gambitc -exe test.c and it compiles well, but when I try to run the exe I get: *** ERROR IN | test| -- Operator is not a PROCEDURE (#!unbound '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated! (I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
After some googling I came across this https://webmail.iro.umontreal.ca/pipermail/gambit-list/2013-September/007054...
The -:s flag is supposed to work with the compiler as well. I tried compiling the file syntax-case.scm and loading it from test.scm, but no luck, the same "Ill-formed expression" error.
It's a bug right? Should I report it on github?
________________________________ From: Bob Coleman bobcolem@yahoo.com Sent: Friday, July 29, 2016 03:37 PM To: ochi n; gambit-list@iro.umontreal.ca Subject: Re: [gambit-list] Error compiling macros
I have no problems running this in the repl. However, I am getting the same issue when using the -exe flag. I believe the syntax-case file needs to be linked into the exe, but I haven't had any luck with that either.
I tried linking syntax-case with the source and using gcc to generate the exe per the manual:
bob@ubuntulaptop:~/home/bob/tmp$ gsc -:s -c gambit-syntax-test.scm bob@ubuntulaptop:~/home/bob/tmp$ gsc -o syntax-case.c -c /usr/local/Gambit-C/current/lib/syntax-case.scm bob@ubuntulaptop:~/home/bob/tmp$ gsc -link gambit-syntax-test.c syntax-case.c bob@ubuntulaptop:~/home/bob/tmp$ gsc -obj gambit-syntax-test.c syntax-case.c syntax-case_.c gambit-syntax-test.c: syntax-case.c: syntax-case_.c: bob@ubuntulaptop:~/home/bob/tmp$ gcc gambit-syntax-test.o syntax-case.o syntax-case_.o -lgambc -lm -ldl -lutil bob@ubuntulaptop:~/home/bob/tmp$ ./a.out *** ERROR IN | gambit-syntax-test| -- Operator is not a PROCEDURE (#!unbound2 '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*) bob@ubuntulaptop:~/home/bob/tmp$
;;;; file: gambit-syntax-test.scm (define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
On Friday, July 29, 2016 10:57 AM, ochi n ochi12@hotmail.com wrote:
I did try adding each one of these: (load "~~lib/syntax-case") (load "~~/lib/syntax-case") (include "~~lib/syntax-case.scm") at the beginning of the file, but I keep getting:
*** ERROR IN "/home/octavio/test.scm"@5.17 -- Ill-formed expression
Where line 5 is:
(syntax-rules ()
I have no idea why this is happening, gambit supports macros and this macros is supposed to be legal. Don't know if it helps, but I'm using the code from this tutorial http://www.willdonnelly.net/blog/scheme-syntax-rules/ A Scheme Syntax-Rules Primer - willdonnellyhttp://www.willdonnelly.net/blog/scheme-syntax-rules/ www.willdonnelly.net Scheme has a wonderfully powerful hygienic macro system. Unfortunately, explanations on how to use it are few and far between. R5RS is utterly incomprehensible to ...
Thanks for your time!
________________________________ From: Bob Coleman bobcolem@yahoo.com Sent: Friday, July 29, 2016 11:22 AM To: ochi n; gambit-list@iro.umontreal.ca Subject: Re: [gambit-list] Error compiling macros
Try manually loading the syntax-case library in test.scm before you use it. With:
(load "~~/lib/syntax-case")
On Friday, July 29, 2016 8:34 AM, ochi n ochi12@hotmail.com wrote:
Hi all, I'm trying to compile a simple program using macros but for some reason it won't work. This is the code in test.scm
(define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error: *** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit" /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' test.o: In function `___setup_mod': test.c:(.text+0xa): undefined reference to `___G__20_test' test.o: In function `___init_mod': test.c:(.text+0x26): undefined reference to `___G__20_test' test.o: In function `___H__20_test': test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x214): undefined reference to `___G_x' test.c:(.text+0x24d): undefined reference to `___G_x' test.c:(.text+0x3a6): undefined reference to `___G_x' test.c:(.text+0x450): undefined reference to `___G_x' test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error' test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error' test.o: In function `____20_test': test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_' test.c:(.text+0xd46): undefined reference to `___S_any' test.c:(.text+0xd62): undefined reference to `___S_body' test.c:(.text+0xd70): undefined reference to `___S_condition' test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any' test.c:(.text+0xd9a): undefined reference to `___S_global' test.c:(.text+0xdc4): undefined reference to `___S_loop' test.c:(.text+0xdd2): undefined reference to `___S_ribcage' test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object' test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage' test.c:(.text+0xe34): undefined reference to `___S_x' collect2: error: ld returned 1 exit status
I tried compiling with the interactive mode using (compile-file-to-target "test.scm") (quit) gambitc -exe test.c and it compiles well, but when I try to run the exe I get: *** ERROR IN | test| -- Operator is not a PROCEDURE (#!unbound '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated! (I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.camailto:Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.camailto:Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
The issue was already reported on github, not much to do other than hope it will be fixed. However, for distributing executables that makes use of macros, I found that one can compile both syntax-case and the code of the application into two separate dynamic libraries. Then bundle the gsi interpreter with both libraries and write a launcher script that does something like this:
./gsi -e "(load "syntax-case.o1") (load "test.o1")"
It's not pretty, but it's supposed to work even on machines where the gambit system is not installed(as gsi, at least on linux, does not have any external dependencies).
And yes, loading syntax-case works unless you're doing it inside a script.
Thanks!
________________________________ From: gambit-list-bounces@iro.umontreal.ca gambit-list-bounces@iro.umontreal.ca on behalf of ochi n ochi12@hotmail.com Sent: Friday, July 29, 2016 04:36 PM To: gambit-list@iro.umontreal.ca; Bob Coleman Subject: Re: [gambit-list] Error compiling macros
After some googling I came across this https://webmail.iro.umontreal.ca/pipermail/gambit-list/2013-September/007054...
The -:s flag is supposed to work with the compiler as well. I tried compiling the file syntax-case.scm and loading it from test.scm, but no luck, the same "Ill-formed expression" error.
It's a bug right? Should I report it on github?
________________________________ From: Bob Coleman bobcolem@yahoo.com Sent: Friday, July 29, 2016 03:37 PM To: ochi n; gambit-list@iro.umontreal.ca Subject: Re: [gambit-list] Error compiling macros
I have no problems running this in the repl. However, I am getting the same issue when using the -exe flag. I believe the syntax-case file needs to be linked into the exe, but I haven't had any luck with that either.
I tried linking syntax-case with the source and using gcc to generate the exe per the manual:
bob@ubuntulaptop:~/home/bob/tmp$ gsc -:s -c gambit-syntax-test.scm bob@ubuntulaptop:~/home/bob/tmp$ gsc -o syntax-case.c -c /usr/local/Gambit-C/current/lib/syntax-case.scm bob@ubuntulaptop:~/home/bob/tmp$ gsc -link gambit-syntax-test.c syntax-case.c bob@ubuntulaptop:~/home/bob/tmp$ gsc -obj gambit-syntax-test.c syntax-case.c syntax-case_.c gambit-syntax-test.c: syntax-case.c: syntax-case_.c: bob@ubuntulaptop:~/home/bob/tmp$ gcc gambit-syntax-test.o syntax-case.o syntax-case_.o -lgambc -lm -ldl -lutil bob@ubuntulaptop:~/home/bob/tmp$ ./a.out *** ERROR IN | gambit-syntax-test| -- Operator is not a PROCEDURE (#!unbound2 '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*) bob@ubuntulaptop:~/home/bob/tmp$
;;;; file: gambit-syntax-test.scm (define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
On Friday, July 29, 2016 10:57 AM, ochi n ochi12@hotmail.com wrote:
I did try adding each one of these: (load "~~lib/syntax-case") (load "~~/lib/syntax-case") (include "~~lib/syntax-case.scm") at the beginning of the file, but I keep getting:
*** ERROR IN "/home/octavio/test.scm"@5.17 -- Ill-formed expression
Where line 5 is:
(syntax-rules ()
I have no idea why this is happening, gambit supports macros and this macros is supposed to be legal. Don't know if it helps, but I'm using the code from this tutorial http://www.willdonnelly.net/blog/scheme-syntax-rules/ A Scheme Syntax-Rules Primer - willdonnellyhttp://www.willdonnelly.net/blog/scheme-syntax-rules/ www.willdonnelly.net Scheme has a wonderfully powerful hygienic macro system. Unfortunately, explanations on how to use it are few and far between. R5RS is utterly incomprehensible to ...
Thanks for your time!
________________________________ From: Bob Coleman bobcolem@yahoo.com Sent: Friday, July 29, 2016 11:22 AM To: ochi n; gambit-list@iro.umontreal.ca Subject: Re: [gambit-list] Error compiling macros
Try manually loading the syntax-case library in test.scm before you use it. With:
(load "~~/lib/syntax-case")
On Friday, July 29, 2016 8:34 AM, ochi n ochi12@hotmail.com wrote:
Hi all, I'm trying to compile a simple program using macros but for some reason it won't work. This is the code in test.scm
(define-syntax while (syntax-rules () ((while condition body ...) (let loop () (if condition (begin body ... (loop)) #f)))))
(define x 0) (while (< x 5) (set! x (+ x 1)) (print x))
When I load the file into the interpreter (with the -:s option) it works, but when I try to compile it (using gambitc -:s -exe test.scm) I get the following error: *** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit" /usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' test.o: In function `___setup_mod': test.c:(.text+0xa): undefined reference to `___G__20_test' test.o: In function `___init_mod': test.c:(.text+0x26): undefined reference to `___G__20_test' test.o: In function `___H__20_test': test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte' test.c:(.text+0x214): undefined reference to `___G_x' test.c:(.text+0x24d): undefined reference to `___G_x' test.c:(.text+0x3a6): undefined reference to `___G_x' test.c:(.text+0x450): undefined reference to `___G_x' test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch' test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error' test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error' test.o: In function `____20_test': test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_' test.c:(.text+0xd46): undefined reference to `___S_any' test.c:(.text+0xd62): undefined reference to `___S_body' test.c:(.text+0xd70): undefined reference to `___S_condition' test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any' test.c:(.text+0xd9a): undefined reference to `___S_global' test.c:(.text+0xdc4): undefined reference to `___S_loop' test.c:(.text+0xdd2): undefined reference to `___S_ribcage' test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object' test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage' test.c:(.text+0xe34): undefined reference to `___S_x' collect2: error: ld returned 1 exit status
I tried compiling with the interactive mode using (compile-file-to-target "test.scm") (quit) gambitc -exe test.c and it compiles well, but when I try to run the exe I get: *** ERROR IN | test| -- Operator is not a PROCEDURE (#!unbound '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while)))) '#<procedure #2> '*top*)
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated! (I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well)
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.camailto:Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.camailto:Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list