Load-form for hash tables is now based on EXT:HASH-TABLE-FILL

This commit is contained in:
Juan Jose Garcia Ripoll 2011-12-10 19:00:30 +01:00
parent 05a46aca0b
commit efc7413d28
2 changed files with 20 additions and 9 deletions

View file

@ -143,6 +143,10 @@ ECL 11.7.1:
invocations of the C compiler. This can be modfied by changing the type
specifier in c:*suppress-compiler-messages*.
- Hash tables can now be printed readably when *READ-EVAL* is true. This is
done using two new functions, EXT:HASH-TABLE-CONTENT and
EXT:HASH-TABLE-FILL.
;;; Local Variables: ***
;;; mode:text ***
;;; fill-column:79 ***

View file

@ -115,15 +115,22 @@ printer and we should rather use MAKE-LOAD-FORM."
(values `(cons ,(maybe-quote (car object)) nil)
(and (rest object) `(rplacd ,(maybe-quote object) ,(maybe-quote (cdr object))))))
(hash-table
(values
`(make-hash-table :size ,(hash-table-size object)
:rehash-size ,(hash-table-rehash-size object)
:rehash-threshold ,(hash-table-rehash-threshold object)
:test ',(hash-table-test object))
`(dolist (i ',(loop for key being each hash-key in object
using (hash-value obj)
collect (cons key obj)))
(setf (gethash (car i) ,object) (cdr i)))))
(let* ((content (ext:hash-table-content object))
(make-form `(make-hash-table
:size ,(hash-table-size object)
:rehash-size ,(hash-table-rehash-size object)
:rehash-threshold ,(hash-table-rehash-threshold object)
:test ',(hash-table-test object))))
(if (need-to-make-load-form-p content)
(values
make-form
`(dolist (i ',(loop for key being each hash-key in object
using (hash-value obj)
collect (cons key obj)))
(setf (gethash (car i) ,object) (cdr i))))
(values
`(ext:hash-table-fill ,make-form ',content)
nil))))
(t
(error "Cannot externalize object ~a" object)))))