anchor.diff:      (symbol key)
       (string (my-intern key :keyword))))
   
  -(defgeneric pdef-key (object)
  -  (:documentation "Get the key (name) of PDEF."))
  -
  -(defmethod pdef-key ((pbind pbind))
  -  (getf (slot-value pbind 'pairs) :pdef))
  -
  -(defgeneric pdef-pattern (object)
  -  (:documentation "Get the pattern that PDEF points to."))
  -
  -(defgeneric pdef-task (object)
  -  (:documentation "Get the task that PDEF was last being played in."))
  +(defgeneric pdef-key (pdef)
  +  (:documentation "The key (name) of PDEF."))
  +
  +(defgeneric pdef-pattern (pdef)
  +  (:documentation "The pattern that PDEF points to."))
  +
  +(defgeneric pdef-pstream (pdef)
  +  (:documentation "The currently-playing pstream of PDEF's pattern."))
  +
  +(defgeneric pdef-task (pdef)
  +  (:documentation "The task that PDEF was last being played in."))
   
   (defpattern pdef (pattern)
     ((key :reader pdef-key)
  
positive.code: 
  See also: `find-pdef', `all-pdefs', `pb', `pmeta', `ps'"
    :defun (defun pdef (key &optional (pattern nil pattern-supplied-p))
             (let ((pdef (ensure-gethash key *pdef-dictionary* (make-instance 'pdef :key key))))
               (when pattern-supplied-p
                 (setf (pdef-pattern pdef) pattern))
               pdef)))
  
  (defun find-pdef (key &optional (errorp nil))
    "Get the pdef named KEY. If one by that name doesn't exist, return nil, or raise an error if ERRORP is true.
  
  See also: `pdef', `all-pdefs'"
    (etypecase key
      (pattern
       key)
      (symbol
       (or (pdef-ref key)
           (when errorp
             (error "Could not find a pdef named ~s." key))))))
  
  (defmethod print-object ((pdef pdef) stream)
    (with-slots (key) pdef
      (format stream "(~s ~s)" 'pdef key)))
  
  (defmethod print-object ((pdef pdef-pstream) stream)
    (with-slots (key) pdef
      (print-unreadable-object (pdef stream :type t)
        (format stream "~s" key))))
  
  (defvar *pdef-dictionary* (make-hash-table)
    "The global pdef dictionary.")
  
  (defun pdef-ref (key &optional (value nil value-provided-p))
    "Retrieve a value from the global pdef dictionary, or set it if VALUE is provided."
    (if value-provided-p
        (if (null value)
            (remhash key *pdef-dictionary*)
            (setf (gethash key *pdef-dictionary*) value))
        (gethash key *pdef-dictionary*)))
  
  (defun all-pdefs (&optional package)
    "Get a list of all pdefs. With PACKAGE, get all pdefs whose key is in that package.
  
  See also: `all-patterns', `playing-pdefs', `all-instruments'"
    (let ((res (keys *pdef-dictionary*)))
      (if package
          (let ((package (etypecase package
                           (package package)
                           (symbol (find-package package)))))
            (remove-if-not
             (lambda (sym)
               (eql (symbol-package sym) package))
             res))
          res)))
  
  (defun playing-pdefs (&optional (clock *clock*))
  
negative.code:           :collect (pdef-key item)))
  
  (defun ensure-pdef (object)
    "Return OBJECT if it is a pdef, otherwise find the pdef pointed to by OBJECT."
    (etypecase object
      (pdef object)
      (string-designator (find-pdef object t))))
  
  (defmethod pdef-key ((pbind pbind))
    (getf (slot-value pbind 'pairs) :pdef))
  
  (defmethod pdef-key ((symbol symbol))
    (pdef-key (pdef-ref (pdef-ensure-key symbol))))
  