Adrien - in addition to what you suggested he wants to define something in case it's unbound.<br><br>What about, based on your macro<br><br><span style="font-family: courier new,monospace;">(define-macro (define/only-if-unbound var-name value)</span><br>

<span style="font-family: courier new,monospace;">  (if (not (symbol? var-name)) (error "Symbol expected"))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  `(define ,var-name (with-exception-catcher</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">                      (lambda (e) ,value)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                      (lambda () ,var-name))))</span><br style="font-family: courier new,monospace;">

<br><br>> (define xyz 1)<br>> (define/only-if-unbound xyz 2)<br>> xyz<br>1<br>> (define/only-if-unbound xyz2 123)<br>> (define/only-if-unbound xyz2 456)<br>> xyz2<br>123<br><br>Only use this kind of coding strategy if you have a really good reason to.<br>

<br>Mikael<br><br><div class="gmail_quote">2011/5/9 Adrien Piérard <span dir="ltr"><<a href="mailto:pierarda@iro.umontreal.ca">pierarda@iro.umontreal.ca</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

What about this?<br>
<br>
(define-macro (bound? x)<br>
  `(with-exception-handler<br>
     (lambda (e) #f)<br>
     (lambda () (and ,x #t))))<br>
<br>
(pp (bound? x))<br>
(let ((y 3))<br>
  (pp (bound? y)))<br>
<br>
<br>
Cheers,<br>
<br>
P!<br>
<br>
2011/5/9 William James <<a href="mailto:w_a_x_man@yahoo.com">w_a_x_man@yahoo.com</a>>:<br>
<div><div></div><div class="h5">> How do you check to see if a symbol is already bound?<br>
> To be used in this fashion:<br>
><br>
> (if (bound? x)<br>
>  (set! x 22)<br>
>  (define x 22))<br>
> _______________________________________________<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" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
><br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Français, English, 日本語, 한국어<br>
</font><div><div></div><div class="h5">_______________________________________________<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" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</div></div></blockquote></div><br>