Hi Jos - <br><br>Thanks for the quick response and the helpful answer (the references/example are great). My motivation for having a conditional define is to make it play nice with the module system, which doesn't work well when having multiple definitions with the same name. I was hoping there is an "automated" way of detecting whether a symbol is already defined in the current module, if so, either override or not import the definition.
<br><br>Of course this is probably circumventing module's design (seems that module is *a lot* stricter than REPL by design), but I am certainly curious on how this could be done. Seems like that compiler would have to keep symbol table(s) internally for all of the defined symbols in order to throw the "already defined" error... ;)
<br><br>Thanks, <br>yinso <br><br><br> <div><span class="gmail_quote">On 4/22/07, <b class="gmail_sendername">jos koot</b> <<a href="mailto:jos.koot@telefonica.net">jos.koot@telefonica.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff">
<div>Oops, the contra-example should read:</div>
<div dir="ltr"> </div>
<div dir="ltr">(require (lib "etc.ss"))</div>
<div> </div>
<div dir="ltr"><span class="q">(define-syntax my-define<br> (syntax-rules ()<br>
((my-define (name . args) . body) (my-define name (lambda args .
body)))<br> ((my-define var value)<br></span> (define var ; <==
correction<span class="q"><br> (begin<br> (printf
"my-define ~a status is ~s~n" 'var<br> (if
(namespace-defined? 'var) 'defined 'undefined))<br>
value)))))</span></div><span class="q">
<div> </div>
<div dir="ltr">(if (read) (namespace-set-variable-value! 'b 2))<br>(my-define b
2)</div>
<div dir="ltr"></div>
<div dir="ltr"> </div>
<div dir="ltr">Jos Koot</div></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.yinsochen.com">http://www.yinsochen.com</a><br>...continuous learning...