This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Reintroducing old `defined?'


Keith Wright <kwright@tiac.net> writes:

 > > From: Roland Orre <orre@nada.kth.se>
 > > 
 > > I think it is time to consider a redefinition of "defined?" to
 > > make it a special form.
 > 
 > There is no mention of "special forms" in RnRS, I assume you mean
 > that you want (defined? x) rather than (defined? 'x).
 > 
 > > *  defined? is still not standardized within the scheme standard
 > >    (thanks Bertrand!) which is a pity as it is an essential procedure
 > >    for everyone who tries to write code which is compatible between
 > >    different interpreters and versions of interpreters.
 > 
 > The problem is that the standard trys to accomodate the needs of
 > compilers as well as interpreters.  If you think of the program
 > as a completed text to be compiled once and then executed repeatedly,
 > then DEFINED? begins to look very odd at best.  Why would you want
 > a dynamic test of whether a variable is defined?  Did you not write
 > the program?  Did you forget what you did?  _All_ variables are
 > defined, otherwise they are not variables, but just some identifers
 > that should not occur in the program at all.

I'm not sure if this was the intended usage, but a defined? special
form would be useful in a compiled context for compatibility between
different scheme implementations for defining what's needed in the
case that it's not provided by the implementation, as in, for example:

(if (not (defined? string->regexp))
   (define (string->regexp s)
      ...))

I guess SLIB addresses this to some extent by providing separate
source code file for each implementation which is written to state
more or less what's provided by the implementation & what needs to be
loaded from SLIB.

-- 
Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il