<div dir="ltr">Hi everyone,<div><br></div><div style>In gambit, when dealing with macros, it became hard to debug because the source information got lost<br></div><div style>in expander so we couldn't generate good debug information.</div>
<div style><br></div><div style>For gambit's internal macros, it mostly use the ##define-syntax to acquire source-object instead of</div><div style>stripped s-expression.</div><div style><br></div><div style>It's doable with lisp style macros, (though it need more work to reimplement your original macros.)</div>
<div style>But things became hard to deal with if taking hygienic macros into consideration, as syntax-rules expander</div><div style>will apply pattern match to the s-expression.</div><div style><br></div><div style>I was wondering if there's any possibilities that make source objects completely transparently to the macro</div>
<div style>expander, for example:</div><div style><br></div><div style><div><font face="courier new, monospace">test.scm:</font></div><div><font face="courier new, monospace"><br></font></div></div><div style><font face="courier new, monospace">(define-syntax test ;; x passed in as a source object</font></div>
<div style><font face="courier new, monospace">  (syntax-rules ()</font></div><div style><font face="courier new, monospace">    ((_ x) (pp (syntax-location x)))))</font></div><div style><br></div><div style><font face="courier new, monospace">(test 3)</font></div>
<div style><font face="courier new, monospace"><br></font></div><div style><font face="courier new, monospace">output:</font></div><div style><font face="courier new, monospace">  File: test.scm, Line: ...</font></div><div style>
<font face="courier new, monospace"><br></font></div><div style><font face="courier new, monospace"><br></font></div><div style><font face="arial, helvetica, sans-serif">I've thought following solutions:</font></div><div style>
<font face="arial, helvetica, sans-serif">1. Make custom exception handlers for type-exception, and recall the procedure if we found the callee args</font></div><div style><font face="arial, helvetica, sans-serif">is an source-object. primitives like car, cdr will work directly</font></div>
<div style><font face="arial, helvetica, sans-serif">pros: No need to do internal changes.</font></div><div style><font face="arial, helvetica, sans-serif">cons: type-exception will not be raised by functions take general parameters, like pp, pair?, list?</font></div>
<div style><font face="arial, helvetica, sans-serif"><br></font></div><div style><font face="arial, helvetica, sans-serif">2. Adding a new subtype, and let every primitives call it as-is.</font></div><div style><font face="arial, helvetica, sans-serif">pros: The whole system worked as is,  there's a </font><span style="font-family:arial,helvetica,sans-serif">similar solution for promise auto-force in gambit so we can</span></div>
<div style><font face="arial, helvetica, sans-serif">refer from.</font></div><div style><font face="arial, helvetica, sans-serif">cons: This will added possible load to runtime system.(every primitives have to check this type and unbox it).</font></div>
<div style><font face="arial, helvetica, sans-serif"><br></font></div><div style>As I'm not an expert to gambit's internal implementation, I would like to ask if there's other possible solution to</div><div style>
this problem?</div><div style><br></div><div style>Thanks</div><div style>Meng</div><div style><br></div><div style><br></div></div>