<div><span style="color: rgb(160, 160, 168); ">On Friday 30 March 2012 at 15:30, Mikael wrote:</span></div>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div><br><div>Den 30 mars 2012 15:39 skrev Per Eckerdal <span dir="ltr"><<a href="mailto:per.eckerdal@gmail.com">per.eckerdal@gmail.com</a>></span>: <blockquote type="cite"><div>

<div>The main drawback of allowing prefix-less global names is that it requires *all* local bindings to be renamed by the auto aliasing, because you can't predict if a local binding will shadow a global one. If all globals had a namespace prefix, auto aliasing would only have to rename bindings that shadow other local bindings, which is fairly rare. This would result in prettier macroexpanded code.</div></div></blockquote><div>Very nice post. Can you give an example that illustrates what you meant with this paragraph?<br></div></div></div></div></span></blockquote><div>Consider the following code:</div><div><br></div><div>ten-times.scm:</div><div><br></div><div><font face="'Courier New'">(define a-name 10)</font></div><div><br></div><div>ten-times#.scm:</div><div><br></div><div><font face="'Courier New'">(define-macro (ten-times code)</font></div><div><font face="'Courier New'">  (let ((loop (gensym))</font></div><div><font face="'Courier New'">        (i (gensym)))</font></div><div><font face="'Courier New'">    (alias</font></div><div><font face="'Courier New'">     (let ,loop ((,i a-name))</font></div><div><font face="'Courier New'">       (if (positive? ,i)</font></div><div><font face="'Courier New'">           (begin</font></div><div><font face="'Courier New'">             ,code</font></div><div><font face="'Courier New'">             (,loop (+ ,i 1))))))))</font></div><div><br></div><div>main.scm:</div><div><br></div><div><span style="font-family: 'Courier New'; ">(##include "ten-times#.scm")</span></div><div><span style="font-family: 'Courier New'; "><br></span></div><div><span style="font-family: 'Courier New'; ">(let ((a-name 5))</span></div><div><font face="'Courier New'">  (execute-ten-times ;; A macro defined somewhere else</font></div><div><font face="'Courier New'">    (println "Five is " a-name)))</font></div><div><br></div><div><br></div><div>(This is, if memory serves me, the way separate compilation and macros are normally done in Gambit today)</div><div><br></div><div>Let's compile this program</div><div><br></div><div>gsc -c ten-times.scm</div><div>gsc -c main.scm</div><div>gsc -o a.out -exe ten-times.c main.c</div><div><br></div><div>The |a-name| global in ten-times.scm will not have any prefix, because the file does not contain any namespace declaration.</div><div><br></div><div>The |a-name| local binding in main.scm will not have any prefix, because the compiler does not know anything about any global or local in the current scope named |a-name| so it believes it's safe to not prefix that particular local binding.</div><div><br></div><div>This results in unhygiene, and the program will only print five lines, instead of the intended ten.</div><div><br></div><div>Because of this, all local bindings must be prefixed by auto-aliasing, even ones that seemingly don't require it, because there is no way to predict if a local binding will shadow a global one.</div><div><br></div><div>If auto-aliasing would rename all local bindings, this code would work. There would still be name clash hazards, but those name clash issues only happen with globals, and are present in Gambit already.</div><div><br></div><div>Regards,</div><div><br></div><div>Per</div><div><br></div>