A semi-deliberate decision, if I recall correctly.
There's been some debate as to what DEFINED? should mean, especially
in the presence of first-class modules, where bindings might go away
over time. There are two consistent definitions I can think of:
1) DEFINED? should be a procedure, which takes an environment value
(e.g., a module object) and a symbol, and tells you whether that
symbol is bound in that environment. This is certainly a well-defined
question.
2) DEFINED? should be a core syntactic form --- not even a macro ---
which is true if its operand, a symbol, is bound in the current
environment. Thus:
(defined? car) => #t
(defined? quote) => #t
(defined? defined?) => #t
(defined? snodgrass) => #f ; take my word for it
(let ((snodgrass 'mom))
(defined? snodgrass)) => #t
Note that defined? is not a constant expression, and cannot be
replaced by one at macro-expansion time.
(define (foo) (defined? bar))
(foo) => #f
(define bar 'zoot)
(foo) => #t
I can't find the root of the original discussion, but I think we
changed it because it implemented something bogus (e.g., always
consulting the "top-level" environment). If anyone can remember,
please let me know.
Is definition 1) above consistent with SCM's behavior?