Anton van Straaten <anton@appsolutions.com> wrote:
+---------------
| > Why do you have (define var (if #f #f)) instead of, say
| > (define var #f)?
|
| (if #f #f) returns an implementation-dependent "unspecified" value. R5RS
| specifies that prior to initialization, variables have an unspecified value.
| "Unspecified" means that an implementation can use any value it likes, but
| for consistency with the host implementation, if you're writing code to
| generate variable definitions, then (if #f #f) usually gives you access to
| whatever value the implementation normally uses to represent an unspecified
| value.
+---------------
CAREFUL! The "unspecified value" that uninitialized variables have is
in no way constrained to be the same as the "unspecified value" which
(if #f #f) returns!! ...and in many implementations it's not! Nor is
the value of (if #f #f) required to be the same as other unspecified
values such as (set! foo 123) [though in many implementations it is].
+---------------
| Most implementations have some kind of "void" value which is used
| for this purpose.
+---------------
It is less common that "void" and (if #f #f) are different [for those
implementations which define a "void"], but I have seen a few. Or consider
MzScheme, where "void" is actually bound to a primitive procedure which
returns a "#<void>" object [which, though, is the same as both (if #f #f)
and (set! foo 123)].
[Also, in MzScheme both (void) and (values) suppress the printing of
any value when returning to the REPL.]
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607