<div>
<div>
<span>
<div><span>This would be help:</span></div><div><span><span class="Apple-tab-span" style="white-space: pre; "> </span><a href="https://mercure.iro.umontreal.ca/pipermail/gambit-list/2006-May/000690.html" style="color: rgb(0, 58, 138); ">https://mercure.iro.umontreal.ca/pipermail/gambit-list/2006-May/000690.html</a></span></div><div><span><br></span></div><div><span>nthcdr will be set at runtime, while macro will be evaluate before it.</span></div>
</span>
<span><br>-- <br>Meng Zhang<br>Sent with <a href="http://www.sparrowmailapp.com">Sparrow</a><br></span>
<p style="color: #a0a0a0;">On 2011年5月1日星期日 at 下午5:02, William James wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div>The followine code is accepted without error when pasted into<br>the REPL, but generates this error when included from a file:<br><br>*** ERROR -- Unbound variable: nthcdr<br><br><br>(define (firstn n lst)<br> (cond<br> ((not n) lst)<br> ((and (positive? n) (pair? lst))<br> (cons (car lst) (firstn (- n 1) (cdr lst))))<br> (else '())))<br><br>(define (nthcdr n lst)<br> (cond<br> ((not n) lst)<br> ((or (< n 1) (null?? lst)) lst)<br> (else (nthcdr (- n 1) (cdr lst)))))<br><br>(define-macro (%with% sequential? var-val-list . body)<br> (let ((paired<br> (let recur ((lst var-val-list) (acc '()))<br> (if (null? lst)<br> (reverse acc)<br> ;; In line below, nthcdr is unbound!! ---------------------<br> (recur (nthcdr 2 lst)<br> (cons (firstn 2 (append lst '('()))) acc))))))<br> (if sequential?<br> `(let* ,paired ,@body)<br> `(let ,paired ,@body))))<br>(define-macro (with var-val-list . body)<br> `(%with% #f ,var-val-list ,@body))<br>(define-macro (with* var-val-list . body)<br> `(%with% #t ,var-val-list ,@body))<br><br>(define (foo)<br> (with (a 2<br> b 9)<br> (println b)))<br><br><br>This is with Gambit v4.6.1 under Windows.<br><brr>_______________________________________________<br>Gambit-list mailing list<br><a href="mailto:Gambit-list@iro.umontreal.ca">Gambit-list@iro.umontreal.ca</a><br><a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br></div></div></span>
</blockquote>
<div>
<br>
</div>
</div>
</div>