Do symbols need to be EQ?

Edi Weitz edi at weitz.de
Fri Jul 3 09:31:55 UTC 2015


On Fri, Jul 3, 2015 at 11:02 AM, Alessio Stalla <alessiostalla at gmail.com> wrote:
> Package = map from symbol name to symbol object.
> INTERN ~= (or (gethash ...) (setf (gethash ...)))
> UNINTERN ~= remhash

I would consider that to be an implementation detail.  As Anton said,
this is mostly about saving space and time.  It would not be
inconceivable to have an "implementation" that worked like so:

(defparameter *my-package* (make-hash-table :test 'equal))

(defun my-intern (symbol-name &optional (package *my-package*))
  (or (gethash symbol-name package)
      (setf (gethash symbol-name package)
            (parse-integer symbol-name))))   ;; <-- imagine some
clever hashing technique

(defun my-unintern (symbol-name &optional (package *my-package*))
  (remhash symbol-name package))

CL-USER > (defparameter *s* (my-intern "42"))
*S*
CL-USER > (my-unintern "42")
T
CL-USER > (eql (my-intern "42") *s*)
T

(Meaning you'd somehow enforce the same "pointer" once the symbol is
"re-created".)



More information about the pro mailing list