<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16414" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>Hi Yinso</DIV>
<DIV>Did you read section 5.2.1 of R5RS? (easily accessible via de help
menu)</DIV>
<DIV>No, namespace-defined? cannot see whether or not the variable will be
defined at run time. Compile and run time are separated. See first section of
chapter 12 of the PLT MzScheme Language manual.</DIV>
<DIV>Keeping track of the defined/undefined status of a variable during
expansion time is a tricky bussines. Even at run time procedure
namespace-defined? only looks at top level bindings; it does not see local
bindings. </DIV>
<DIV>In case procedure namespace-set-variable-value! is used, especially when
called within a conditional form, it is even impossible to predict during
expansion time whether or not a variable will be defined at top level. </DIV>
<DIV> </DIV>
<DIV>For example:</DIV>
<DIV> </DIV>
<DIV>(require (lib "etc.ss"))</DIV>
<DIV> </DIV>
<DIV>(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> (define name<BR>
(begin<BR> (printf "my-define ~a status is ~s~n"
'var<BR> (if (namespace-defined? 'var) 'defined
'undefined))<BR> value)))))</DIV>
<DIV> </DIV>
<DIV>(if (read) (namespace-set-variable-value! 'b 2))<BR>(my-define b 2)</DIV>
<DIV><BR> </DIV>
<DIV>Jos Koot</DIV>
<DIV> </DIV>
<DIV>(((((lambda(x)((((((((x x)x)x)x)x)x)x)x))<BR>
(lambda(x)(lambda(y)(x(x y)))))<BR> (lambda(x)(x)x))<BR>
(lambda()(printf "Greetings, Jos~n"))))</DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=yinso.chen@gmail.com href="mailto:yinso.chen@gmail.com">Yin-So
Chen</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=plt-scheme@list.cs.brown.edu
href="mailto:plt-scheme@list.cs.brown.edu">mzscheme Mailing List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, April 22, 2007 10:57
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [plt-scheme] verifying whether a
symbol is defined at compile time?</DIV>
<DIV><BR></DIV>Hi all - <BR><BR>Is there a way to verify whether a symbol is
defined (or imported) at compile time? I am trying to write a
conditional define macro (e.g. define-once) that will evaluate to define if
the variable is not previously defined, but struggling to figure out how to
determine whether a symbol's existence. (namespace-defined? v) doesn't
appear to work for compile-time. <BR><BR>Thanks,<BR>yinso <BR><BR>--
<BR><A
href="http://www.yinsochen.com">http://www.yinsochen.com</A><BR>...continuous
learning...
<P>
<HR>
<P></P>_________________________________________________<BR> For
list-related administrative tasks:<BR>
http://list.cs.brown.edu/mailman/listinfo/plt-scheme<BR></BLOCKQUOTE></BODY></HTML>