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

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)
      ) )

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

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 '().