<div dir="ltr">for the first issue, I apologize, I wrote the test example from my cell phone, and forgot the backquote, it should have been:<div><br></div><div><span style="color:rgb(80,0,80)">(define-macro (test x . args) `(list ,@(map car args)))</span><br style="color:rgb(80,0,80)"><span style="color:rgb(80,0,80)">(test 10 ('x 1) ('y 2))</span><br></div><div><span style="color:rgb(80,0,80)"><br></span></div>which crashes S7, when I load from c string this snippet. The bt from gdb looks like this:<div><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>Thread 1 "tic80" received signal SIGSEGV, Segmentation fault.<br>0x00005555559bb97d in s7_integer (p=0x0) at /home/david/hacking/tic80-s7/TIC-80/vendor/s7/s7.c:13462<br>13462         if (is_t_integer(p)) return(integer(p));<br>(gdb) bt<br>#0 0x00005555559bb97d in s7_integer (p=0x0) at /home/david/hacking/tic80-s7/TIC-80/vendor/s7/s7.c:13462<br>#1 0x00005555558e136b in scheme_map (sc=0x555556e456a0, args=0x55555761d9b8)<br> at /home/david/hacking/tic80-s7/TIC-80/src/api/scheme.c:313<br>#2 0x0000555555b27873 in op_c_ss (sc=0x555556e456a0) at /home/david/hacking/tic80-s7/TIC-80/vendor/s7/s7.c:87854<br>#3 0x0000555555b340e1 in eval (sc=0x555556e456a0, first_op=420) at /home/david/hacking/tic80-s7/TIC-80/vendor/s7/s7.c:90383<br>#4 0x00005555559f8899 in s7_load_c_string_with_environment (sc=0x555556e456a0, <br> content=0x7fffe69dde08 ";; title: game title\n;; author: game developer, email, etc.\n;; desc: short description\n;; site: website link\n;; license: MIT License (change this to your license of choice)\n;; version: 0.1\n;;"..., bytes=2524, <br> e=0x5555570ae610) at /home/david/hacking/tic80-s7/TIC-80/vendor/s7/s7.c:30466<br>#5 0x00005555559f89fc in s7_load_c_string (sc=0x555556e456a0, <br> content=0x7fffe69dde08 ";; title: game title\n;; author: game developer, email, etc.\n;; desc: short description\n;; site: website link\n;; license: MIT License (change this to your license of choice)\n;; version: 0.1\n;;"..., bytes=2524)<br> at /home/david/hacking/tic80-s7/TIC-80/vendor/s7/s7.c:30482<br>#6 0x00005555558e3367 in initScheme<span style="color:rgb(80,0,80)"><br></span></div></blockquote><br><div>For my issue 2, about having a set! only working in some circonstances, I was expecting the macro to be expanded (thus producing the "(car x)" code and since car handles the set! call properly I expected to work. Is this a deviation from the standard or that I have a misconception of how it should work? I tried it in gsi and it worked well, but guile even fails to eval "(set! (car x) 3)" so maybe it is to the implementation to decide how this works?</div></div><div><br></div><div>In my endeavour to use S7 in tic-80, I faced a few roadblocks on some platforms (windows, rasberry pi and android, mostly). You can see the details here if you are interested:<br><a href="https://github.com/nesbox/TIC-80/pull/2113">https://github.com/nesbox/TIC-80/pull/2113</a><br></div><div><br></div><div>Windows issues were related to the use of noreturn hints. I didn't know how to fix it properly so I just removed them for now and it seems fine. I had less obvious issues on Android which had issues with the cpow and clog macros being undefined. Finally on rasberry pi, the issue was related to the type sigjmp_buf being undefined, which I'm still trying to resolve. I don't know if those changes I'm doing are relevant to you but I thought I would let you know.</div><div><br></div><div>Finally, I mentionned performance issues in my first email, but I was quite wrong. I optimized my code a bit and also did better measurements and it's actually running very smoothly ;p Apologies!</div><div><br></div><div>Thanks!</div><div><br></div><div>--</div><div>David</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 2, 2023 at 1:53 PM <<a href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks for the info and bug reports. Are you catching<br>
scheme errors or using a repl? In the repl, I get:<br>
<br>
<br>
(define-macro (test x . args) (list ,@(map car args)))<br>
(test 10 ('x 1) ('y 2))<br>
<br>
;unquote (',') occurred outside quasiquote: (test 10 ('x 1) ('y 2))<br>
; (test 10 ('x 1) ('y 2))<br>
; test: (list (unquote (apply-values (map c... ; args: (('x 1) ('y 2))<br>
<br>
In other words, you have ",@(...)" but there's no enclosing<br>
quasiquote.<br>
<br>
<br>
(define-macro (test x) `(car ,x))<br>
(let ((x (cons 1 2))) (set! (test x) 3) x)<br>
<br>
;test (a macro) does not have a setter: (set! (test x) 3)<br>
<br>
The code (set! (test...)...) only works if the test macro<br>
has a setter (a function that tells set! how to handle it<br>
as the target of set!). Your other case<br>
<br>
(let ((x (cons 1 2))) (set! (car x) 3) x)<br>
;(3 . 2)<br>
<br>
works because car has a built-in setter in s7 (set-car! is<br>
the standard scheme equivalent).<br>
<br>
If you're using s7_eval_c_string or other C-side equivalent,<br>
you need to catch scheme-side errors. There's a section in<br>
s7.html showing one way to do this ("handling scheme errors<br>
in C" or some such title).<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">David</div>