|
From: Michael T. <mt...@bb...> - 2004-11-04 19:53:42
|
I'm not sure I agree: what is wrong with defining #f and #null as
semantically equivalent? Even if #null printed as #f, it might be
better than the current situation. Bottom line is that #null is a
projection of a non-scheme thing into scheme space - it is up to jscheme
to manage that projection in whatever way makes the most sense. What if
we got rid of #null altogether?... or make #null a variable bound to #f.
cheers,
-mik
P.S. what bugs me is having to do (equal? foo #null):
> (or (null? #null) (not #null))
#f
Geoffrey Knauth wrote:
> As a practical matter, it certainly seems convenient to be able to
> treat #null the same as #f in conditionals--I agree it is
> counterintuitive to have #null be not-false.
>
> But I'm concerned about breaking R5RS 6.3.1., "only #f counts as false
> in conditional expressions,"
>
> http://www.swiss.ai.mit.edu/~jaffer/r5rs_8.html#SEC58
>
> note: (not '()) ==> #f
>
> and 3.2, "no object satisfies more than one of the following
> predicates: boolean? pair? symbol? number? char? string? vector? port?
> procedure?"
>
> http://www.swiss.ai.mit.edu/~jaffer/r5rs_5.html#SEC20
>
> So we'd have to caveat the language standard, and surprise newcomers
> to JScheme from other Schemes. On the principle of least surprise,
> we'd probably be 50-50 between surprising newcomes to JScheme from
> other languages vs. other Schemes.
>
> In Java you can't do: Object o = NULL; if (o) { true-stuff} else {
> false-stuff }
> you have to do: if (o == NULL) ...
> It's a pain in the butt, but it's been drilled into us.
>
> Reluctantly, I suggest leaving #null and the semantics of `if' alone,
> and offering a "new" `if', e.g., `jif', that would treat #null as #f.
>
> By the way, I tried to figure out what #null is in JScheme, and it
> isn't anything:
>
> > (symbol? #null)
> #f
> > (boolean? #null)
> #f
> > (pair? #null)
> #f
> > (vector? #null)
> #f
> > (procedure? #null)
> #f
> > (string? #null)
> #f
> > (port? #null)
> (port? '#null)
> ====================================
> SchemeException: ERROR: undefined variable "port?"
> > (number? #null)
> #f
> > (char? #null)
> #f
>
> Then I remembered that the empty list '() isn't anything either, but
> it also isn't #null:
>
> > (eq? '() #null)
> #f
> > (eqv? '() #null)
> #f
> > (equal? '() #null)
> #f
and, of course,
> (null? #null)
#f
As an alternative, what about defining #f and #null as the same object?
|