<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>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:</p>
<p><br>
</p>
<p>    ./gsi -e "(load \"syntax-case.o1\") (load \"test.o1\")"<br>
</p>
<p><br>
</p>
<p>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).</p>
<p>And yes, loading syntax-case works unless you're doing it inside a script.</p>
<p><br>
</p>
<p>Thanks!<br>
</p>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> gambit-list-bounces@iro.umontreal.ca <gambit-list-bounces@iro.umontreal.ca> on behalf of ochi n <ochi12@hotmail.com><br>
<b>Sent:</b> Friday, July 29, 2016 04:36 PM<br>
<b>To:</b> gambit-list@iro.umontreal.ca; Bob Coleman<br>
<b>Subject:</b> Re: [gambit-list] Error compiling macros</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>After some googling I came across this <a id="LPlnk159324" href="https://webmail.iro.umontreal.ca/pipermail/gambit-list/2013-September/007054.html" class="OWAAutoLink">
https://webmail.iro.umontreal.ca/pipermail/gambit-list/2013-September/007054.html</a></p>
<p>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
<span>"Ill-formed expression</span>" error.<br>
</p>
<p>It's a bug right? Should I report it on github?<br>
</p>
<br>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Bob Coleman <bobcolem@yahoo.com><br>
<b>Sent:</b> Friday, July 29, 2016 03:37 PM<br>
<b>To:</b> ochi n; gambit-list@iro.umontreal.ca<br>
<b>Subject:</b> Re: [gambit-list] Error compiling macros</font>
<div> </div>
</div>
<div>
<div style="color:#000; background-color:#fff; font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:16px">
<div id="yui_3_16_0_ym19_1_1469716374681_26504">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.</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26505"><br id="yui_3_16_0_ym19_1_1469716374681_26506">
</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26507">I tried linking syntax-case with the source and using gcc to generate the exe per the manual:</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26508"><br id="yui_3_16_0_ym19_1_1469716374681_26509">
</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26510">bob@ubuntulaptop:~/home/bob/tmp$ gsc -:s -c gambit-syntax-test.scm</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26511">bob@ubuntulaptop:~/home/bob/tmp$ gsc -o syntax-case.c -c /usr/local/Gambit-C/current/lib/syntax-case.scm</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26512">bob@ubuntulaptop:~/home/bob/tmp$ gsc -link gambit-syntax-test.c syntax-case.c</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26513">bob@ubuntulaptop:~/home/bob/tmp$ gsc -obj gambit-syntax-test.c syntax-case.c syntax-case_.c</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26514">gambit-syntax-test.c:</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26515">syntax-case.c:</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26516">syntax-case_.c:</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26517">bob@ubuntulaptop:~/home/bob/tmp$ gcc gambit-syntax-test.o syntax-case.o syntax-case_.o -lgambc -lm -ldl -lutil</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26518">bob@ubuntulaptop:~/home/bob/tmp$ ./a.out</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26519">*** ERROR IN | gambit-syntax-test| -- Operator is not a PROCEDURE</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26520">(#!unbound2</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26521"> '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while))))</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26522"> '#<procedure #2></div>
<div id="yui_3_16_0_ym19_1_1469716374681_26523"> '*top*)</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26524">bob@ubuntulaptop:~/home/bob/tmp$</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26525"><br id="yui_3_16_0_ym19_1_1469716374681_26526">
</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26527"><br id="yui_3_16_0_ym19_1_1469716374681_26528">
</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26529">;;;; file:  gambit-syntax-test.scm</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26530">(define-syntax while</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26531">  (syntax-rules ()</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26532">    ((while condition body ...)</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26533">     (let loop ()</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26534">       (if condition</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26535">           (begin</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26536">             body ...</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26537">             (loop))</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26538">           #f)))))</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26539"><br id="yui_3_16_0_ym19_1_1469716374681_26540">
</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26541">(define x 0)</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26542">(while (< x 5)</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26543">  (set! x (+ x 1))</div>
<div id="yui_3_16_0_ym19_1_1469716374681_26452"></div>
<div id="yui_3_16_0_ym19_1_1469716374681_26544">  (print x))</div>
<div dir="ltr" id="yui_3_16_0_ym19_1_1469716374681_26545"><br id="yui_3_16_0_ym19_1_1469716374681_26546">
</div>
<div class="qtdSeparateBR"><br>
<br>
</div>
<div class="yahoo_quoted" style="display:block">
<div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:16px">
<div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:16px">
<div dir="ltr"><font face="Arial" size="2">On Friday, July 29, 2016 10:57 AM, ochi n <ochi12@hotmail.com> wrote:<br>
</font></div>
<br>
<br>
<div class="y_msg_container">
<div id="yiv1090503675">
<div dir="ltr">
<div id="yiv1090503675divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div>I did try adding each one of these: (load "~~lib/syntax-case") <span>(load "~~/lib/syntax-case")</span> <span>(include "~~lib/syntax-case.scm")</span> at the beginning of the file, but I keep getting:</div>
<div><br clear="none">
</div>
<div><span>*** ERROR IN "/home/octavio/test.scm"@5.17 -- Ill-formed expression</span></div>
<div><span><br clear="none">
</span></div>
<div><span>Where line 5 is:<br clear="none">
</span></div>
<div><span></span><br clear="none">
</div>
<div><span>(syntax-rules ()</span></div>
<div><span><br clear="none">
</span></div>
<div>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
<a rel="nofollow" shape="rect" class="yiv1090503675OWAAutoLink" id="LPlnk482971" target="_blank" href="http://www.willdonnelly.net/blog/scheme-syntax-rules/">
http://www.willdonnelly.net/blog/scheme-syntax-rules/</a></div>
<div id="LPBorder_GT_14698195406710.42297493238240147" style="margin-bottom:20px; overflow:auto; width:100%; text-indent:0px">
<table id="LPContainer_14698195406630.07824821185626751" style="width:90%; background-color:rgb(255,255,255); overflow:auto; padding-top:20px; padding-bottom:20px; margin-top:20px; border-top:1px dotted rgb(200,200,200); border-bottom:1px dotted rgb(200,200,200)" cellspacing="0">
<tbody>
<tr style="border-spacing:0px" valign="top">
<td colspan="2" id="TextCell_14698195406650.5245542788705141" style="vertical-align: top; padding: 0px; display: table-cell; position: relative;">
<div id="LPRemovePreviewContainer_14698195406660.9043506922950391"></div>
<div id="LPTitle_14698195406660.722251829357328" style="top:0px; color:rgb(0,120,215); font-weight:400; font-size:21px; font-family:"wf_segoe-ui_light","Segoe UI Light","Segoe WP Light","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif; line-height:21px">
<a target="_blank" href="http://www.willdonnelly.net/blog/scheme-syntax-rules/" id="LPUrlAnchor_14698195406670.24474907797157364" style="text-decoration:none">A Scheme Syntax-Rules Primer - willdonnelly</a></div>
<div id="LPMetadata_14698195406680.03834439948275814" style="margin:10px 0px 16px; color:rgb(102,102,102); font-weight:400; font-family:"wf_segoe-ui_normal","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif; font-size:14px; line-height:14px">
www.willdonnelly.net</div>
<div id="LPDescription_14698195406690.860622158833548" style="display:block; color:rgb(102,102,102); font-weight:400; font-family:"wf_segoe-ui_normal","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif; font-size:14px; line-height:20px; max-height:100px; overflow:hidden">
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 ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<div>Thanks for your time!<br clear="none">
</div>
<div><br clear="none">
</div>
<div class="yiv1090503675yqt6274136178" id="yiv1090503675yqt26423">
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div dir="ltr" id="yiv1090503675divRplyFwdMsg"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Bob Coleman <bobcolem@yahoo.com><br clear="none">
<b>Sent:</b> Friday, July 29, 2016 11:22 AM<br clear="none">
<b>To:</b> ochi n; gambit-list@iro.umontreal.ca<br clear="none">
<b>Subject:</b> Re: [gambit-list] Error compiling macros</font>
<div> </div>
</div>
<div>
<div style="color:#000; background-color:#fff; font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:16px">
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11245">Try manually loading the syntax-case library in test.scm before you use it.  With:</div>
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11246"><br id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11247" clear="none">
</div>
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11216"></div>
<div id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11248">(load "~~/lib/syntax-case")</div>
<div dir="ltr" id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11249"><br id="yiv1090503675yui_3_16_0_ym19_1_1469716374681_11250" clear="none">
</div>
<div class="yiv1090503675qtdSeparateBR"><br clear="none">
<br clear="none">
</div>
<div class="yiv1090503675yahoo_quoted" style="display:block">
<div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:16px">
<div style="font-family:HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size:16px">
<div dir="ltr"><font face="Arial" size="2">On Friday, July 29, 2016 8:34 AM, ochi n <ochi12@hotmail.com> wrote:<br clear="none">
</font></div>
<br clear="none">
<br clear="none">
<div class="yiv1090503675y_msg_container">
<div id="yiv1090503675">
<div dir="ltr">
<div id="yiv1090503675divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<div>Hi all, I'm trying to compile a simple program using macros but for some reason it won't work.</div>
<div>This is the code in test.scm</div>
<div><br clear="none">
</div>
<div></div>
<div>    (define-syntax while<br clear="none">
<span>    </span>  (syntax-rules ()<br clear="none">
<span>    </span>    ((while condition body ...)<br clear="none">
<span>    </span>     (let loop ()<br clear="none">
<span>    </span>       (if condition<br clear="none">
<span>    </span>           (begin<br clear="none">
<span>    </span>             body ...<br clear="none">
<span>    </span>             (loop))<br clear="none">
<span>    </span>           #f)))))<br clear="none">
<br clear="none">
<span>    </span>(define x 0)<br clear="none">
<span>    </span>(while (< x 5)<br clear="none">
<span>    </span>  (set! x (+ x 1))<br clear="none">
<span>    </span>  (print x))<br clear="none">
<br clear="none">
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:<br clear="none">
<div>*** ERROR -- missing or invalid linking information for module "/usr/lib/gambit-c/_gambit"<br clear="none">
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.1/../../../../lib/crt1.o: In function `_start':<br clear="none">
(.text+0x20): undefined reference to `main'<br clear="none">
test.o: In function `___setup_mod':<br clear="none">
test.c:(.text+0xa): undefined reference to `___G__20_test'<br clear="none">
test.o: In function `___init_mod':<br clear="none">
test.c:(.text+0x26): undefined reference to `___G__20_test'<br clear="none">
test.o: In function `___H__20_test':<br clear="none">
test.c:(.text+0x113): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x181): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x1a2): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x1f3): undefined reference to `___G__24_sc_2d_put_2d_cte'<br clear="none">
test.c:(.text+0x214): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x24d): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x3a6): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x450): undefined reference to `___G_x'<br clear="none">
test.c:(.text+0x59b): undefined reference to `___G__24_syntax_2d_dispatch'<br clear="none">
test.c:(.text+0x60f): undefined reference to `___G__24_syntax_2d_dispatch'<br clear="none">
test.c:(.text+0x6a0): undefined reference to `___G_syntax_2d_error'<br clear="none">
test.c:(.text+0x6fa): undefined reference to `___G_syntax_2d_error'<br clear="none">
test.o: In function `____20_test':<br clear="none">
test.c:(.text+0xd38): undefined reference to `___S__2a_top_2a_'<br clear="none">
test.c:(.text+0xd46): undefined reference to `___S_any'<br clear="none">
test.c:(.text+0xd62): undefined reference to `___S_body'<br clear="none">
test.c:(.text+0xd70): undefined reference to `___S_condition'<br clear="none">
test.c:(.text+0xd8c): undefined reference to `___S_each_2d_any'<br clear="none">
test.c:(.text+0xd9a): undefined reference to `___S_global'<br clear="none">
test.c:(.text+0xdc4): undefined reference to `___S_loop'<br clear="none">
test.c:(.text+0xdd2): undefined reference to `___S_ribcage'<br clear="none">
test.c:(.text+0xdee): undefined reference to `___S_syntax_2d_object'<br clear="none">
test.c:(.text+0xe18): undefined reference to `___S_top_2d_ribcage'<br clear="none">
test.c:(.text+0xe34): undefined reference to `___S_x'<br clear="none">
collect2: error: ld returned 1 exit status</div>
<br clear="none">
I tried compiling with the interactive mode using <br clear="none">
    (compile-file-to-target "test.scm")<br clear="none">
    (quit)<br clear="none">
    gambitc -exe test.c<br clear="none">
and it compiles well, but when I try to run the exe I get:<br clear="none">
<div>    *** ERROR IN | test| -- Operator is not a PROCEDURE<br clear="none">
<span>    </span>(#!unbound<br clear="none">
<span>    </span> '#(syntax-object while ((top) #(ribcage #(while) #((top)) #(while))))<br clear="none">
<span>    </span> '#<procedure #2><br clear="none">
<span>    </span> '*top*)<br clear="none">
<br clear="none">
No matter how hard I try I can't compile any code that makes use of macros. Any help appreciated!<br clear="none">
</div>
<span>(I'm using Arch Linux and I installed gambit from Arch's repositroy, everything else apart from macros works well</span>)<br clear="none">
</div>
<div></div>
</div>
</div>
</div>
<br clear="none">
_______________________________________________<br clear="none">
Gambit-list mailing list<br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br clear="none">
<a rel="nofollow" shape="rect" target="_blank" href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br clear="none">
<br clear="none">
<br clear="none">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="yqt6274136178" id="yqt40920">_______________________________________________<br clear="none">
Gambit-list mailing list<br clear="none">
<a shape="rect" href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br clear="none">
<a shape="rect" href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br clear="none">
</div>
<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>