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


    Date:  5 February 1987 17:36 mst
    From:  coffee at AEROSPACE.AERO.ORG
    Subject:  Re: REMF and REMPROP

    From Steele, p.165: "Note that there is no way to distinguish an absent
    property from one whose value is <default>." The <default> argument is
    optional and defaults in turn to nil, so get on an absent property is
    normally identical in value to get on a property with explicit value nil.
    Winston & Horn, p.97, shows (setf (get <sym> <prop>) nil) as equivalent
    to remprop "as far as get is concerned...although it is better programming
    practice to use remprop."
                                                                Cheers, Pc^2

Since the caller of GET can specify the default value, it would not be
valid for REMPROP to set it to NIL.  Consider the difference between
          (REMPROP 'foo :bar)
          (GET 'foo :bar 'my-default) => my-default
          (SETF (GET 'foo :bar) NIL)
          (GET 'foo :bar 'my-default) => NIL

So, while the caller of GET cannot distinguish a missing value from the
default value, GET must be able to detect that a property is missing.

By the way, here is a function that reliably provides the two-value
interface I described:

(defun my-get (symbol indicator &aux (default (ncons nil)))
  (let ((value (get symbol indicator default)))
    (if (eq value default)
        (values nil nil)
      (values value t))))