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] |
Mikael Djurfeldt <mdj@nada.kth.se> writes: > Roland Orre <orre@nada.kth.se> writes: > > > I think it is time to consider a redefinition of "defined?" to > > make it a special form. > > Me too. I was against changing `defined?' into a procedure from the > very start. I was the one who changed `defined?' into a procedure. Since then, I have time and time again tried to remember the reasoning I used back then, but couldn't. So, the executive summary is: I don't object to making `defined?' a special form. But. I think we should first find out what `defined?' really means in the context of modules. I prefer to use the more explicit `module-defined?' instead anyway (which is a procedure and should definitely stay one). Right now, `defined?' could be defined like (define (defined? sym) (module-defined? (current-module) sym)) Is this what we want? Or should it check local bindings as well (for the benefit of macros)? Should it be a memoizing macro, or not? If it is memoizing (helping with tremendously with speed), it might not detect a changing top-level environment. So it might have to memoize to an actual call to `module-defined?' maybe when it examines the top-level environment. I have never really made my mind up about these issues, that's why I don't have a strong position. But I very much agree with Greg about: "why make it a macro when it only saves a single quote." When `defined?' gets sematics that require it to be a special form, then we have no choice, but given the choice, I prefer procedures. > * 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. I'm not sure if it really is easier. If you see this as an optimization, then I don't think that being a macro makes it significantly easier for the compiler to do constant-folding. > *** I suggest that we rename the current `defined?' into `bound?' and > re-introduce scm's special form `defined?'. I would prefer to stick to `module-defined?' and require people to be explicit about module issues. - Marius