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] |
> 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. > * In the current guile definition defined? is a procedure which > evaluates its arguments. This is rather counterintuitive when > both "define" and "undefine" are special forms. DEFINE is not a special form, either, in the Lisp1.5 sense of corresponding to a procedure that does not evaluate its arguments. It is "essential syntax", i.e. a unique kind of program text that is not an expression or variable at all, and corresponds to no object in storage. > Ok "undefine" is > not yet standardized either, but should be considered being > standardized in the scheme standard as well, as non essential. > Long running applications and shells etc need to be able to clean up. The Garbage Collector cleans up storage. Long running applications do not typically use up variables as they run; there is a fixed set set of them defined in the text of the program, which does not change. The only use I see for UNDEFINE is during interactive development when you discover you have made a boo-boo. Even then it doesn't do much that couldn't be done by (define boo-boo #f). I see DEFINED? as analogous to EVAL. For certain special purposes (_not_ in ordinary applications) it is useful to treat lists of symbols as programs. As part of that project, one may want to know whether a symbol corresponds to a variable. One could imagine a combined function: (EVAL/DEFINED? <expression>) - returns a list of the value(s) of the expression if it is defined, otherwise #f. (eval/defined? 'n) ==> #f (define n 2) (eval/defined? 'n) ==> (2) (eval/defined? '(* n n)) ==> (4) (eval/defined? '(/ n 0)) ==> #f (eval/defined? '(values n (+ 1 n))) ==> (2 3) > * I guess that there are more people out there who prefer defined? > to be a special form. Any objections? Let's think about this for a while. My first reaction is to object. > From: Mikael Djurfeldt <mdj@nada.kth.se> > > I'd like to add the following argument: > > * If `defined?' is a special form, it is easier for a compiler or a > macro expander to expand conditionals testing for existence of a > binding at compilation/macro expansion time. `defined?' could, in > this respect, be used for conditional compilation. I would like to see this worked out in more detail before I endorse it. In particular, conditional compilation should be based on the values of well-defined variables which are known at compile time, not on whether or not some identifer happens to already have a definition. How would it get a definition other than by being part of the program text, possibly as a result of conditional compilation? > In fact, I think this is such a good suggestion that I will do this > within a week from now, unless someone stops me. I can't stop you, but I think flip-flopping back and forth is the worst possible outcome. Before changing it back, it would be good to know who changed it to what it is, and why they did it. > From: Bertrand Petit <elrond@phoe.netdev.net> > > I agree with you. After this is done in guile, one should > persuade the rnrs authors to include this in the next edition. I doubt they will do that, because consensus will be blocked by the compiler authors. Nobody has ever proposed such a feature for C, and with good reason. -- -- Keith Wright <kwright@free-comp-shop.com> Programmer in Chief, Free Computer Shop <http://www.free-comp-shop.com> --- Food, Shelter, Source code. ---