[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
visible hash tables
I have always thought that an extension to the #S macro
is the correct way to do this sort of thing.
Might I instead suggest
#S(hash-table :test #'eq :initial-contents #)
Such an extension would also allow one to present *PRINT-ESCAPE*
pathnames along the lines of
#S(pathname "FOO.EDU:>File-Server>barfmail.lisp")
Similarly
#S(byte-specifier 69 259)
#S(random-state ...)
and so forth.
In CLOSsage, I guess the way to do this would be have the reader call
a generic function whose methods are defined on either a class instance
or, somewhat less flexibly, `on' the prototype instance of a class.
(defmethod construct-instance-from-cruft-read-by-\#S
((class (eql (find-class 'pathname)))
&rest initargs)
(apply (lambda (name)
(pathname name))
initargs))
(defmethod construct-instance-from-cruft-read-by-\#S
((class structure-class)
&rest initargs)
(apply (secret-internal-constructor class) initargs))
I believe that this sort of approach was implemented in NIL
at some stage. RMS' lisp machine code had a similar feature.
[Then again, one could always print
"#.(let ((table (make-hash-table :test #'eql)))
(dolist (x '((key1 . val1) ...))
(setf (gethash table (car x)) (cdr x)))))"
Yum!]