From: Timothy J. H. <ti...@cs...> - 2004-11-04 20:54:47
|
On Nov 4, 2004, at 2:50 PM, Michael Thome wrote: > I'm not sure I agree: what is wrong with defining #f and #null as > semantically equivalent? I would side with Rusty and Geoffrey. One problem with identifying #f and #null is that they have different semantics in Java and hence would create problems when calling Java methods/constructors etc. e.g. to create a Boolean array of size 4 and store two Boolean values in it, we could use > (define f (list->array Boolean.class '( #f #t #null #null))) But if #f and #null were identified, we would not be able to represent #null > Even if #null printed as #f, it might be better than the current > situation. Again, it would create problems when working with the Java interface. You would like to know when a Boolean function is returning #null or #f. > 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. True, but we want the Scheme space to embed into Java space as well. > 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 I agree with Rusty that macros would provide a mechanism for getting this kind of behavior. > > 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? > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: > Sybase ASE Linux Express Edition - download now for FREE > LinuxWorld Reader's Choice Award Winner for best database on Linux. > http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |