[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: disjointness of '() and #f




>> 
>>     This is a frequent source of confusion in data structures where 2 pieces
>>     of information is desired: (1) was an action successful? (2) if
>>     successful, what was the value of the result? [multiple value returns is
>>     another discussion].  As (2) is only interesting in the success case, the
>>     attempt is made to overload the returned value for two uses.  E.g.
>> 
>>       (let ( (probe (table-lookup table key)) )
>> 	(if probe
>> 	    (success-action probe)
>> 	    (failure-action)
>>       ) )
>> 
>>     This works as long as the value of PROBE is #f XOR a valid data value.
[JINX]
>> 
>> What happens when key is in the table, and its associated value is #f?
>> You don't remove the problem by mandating (eq? #f '()) to be #f, you
>> have just hidden one instance of it.  The real problem is #f, not '().

I was pointing out a problem which I often see.  The implicit assumptions
were given as:

[A] "Never use #f in a data context, only in a control context".

[B] This works as long as the value of PROBE is #f XOR a valid data value.


]My only observation is that a multiple value return is useful to me
here.[


There are other symptoms e.g. [someone else mad at me--sorry], in T's 3.1
runtime (make-vector 5 '()) -> #(0 0 0 0 0).  It was easy to fix this to
return the proper #(() () () () ()).  It happened to break assumptions in
the program I was working on, but it code me an hour or two [OK, I'm
slow].

There are just too many cases of this same oversight.

-Ken