- Edi Weitz rqv@jrvgm.qr [2015-07-03 11:31:55 +0200]:
On Fri, Jul 3, 2015 at 11:02 AM, Alessio Stalla alessiostalla@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".)
this behavior is non-compliant.
http://www.lispworks.com/documentation/HyperSpec/Body/f_intern.htm
If no such symbol is accessible in package, a new symbol with the given name is created
i.e., after unintern, there is no symbol with this name, thus intern creates a _NEW_ symbol which cannot be EQ to any other existing object (this is the definition of the word "new" or "fresh").