Require explicit enabling of hash-table reader macro.

This commit is contained in:
Kyle 2015-04-06 10:50:07 -07:00
parent e14ffc164f
commit 45ef5eddb4
1 changed files with 9 additions and 4 deletions

View File

@ -30,7 +30,11 @@
(setq key-p t
v (read-from-string (finalise-read v)))
(setf (gethash k m) v)
(setq k nil v nil)))))
(setq k nil v nil))))
(reading-complete-p ()
(and (null v)
(not
(null k)))))
(do ((prev (read-char stream) curr)
(curr (read-char stream) (read-char stream)))
((and (char= prev #\}) (char= curr #\#)))
@ -39,14 +43,15 @@
(if key-p
(push prev k)
(push prev v))))
(if (and (null v) (not (null k)))
(if (reading-complete-p)
(error "Mismatched key value pairs.")
(progn
(finalise-kv-pair)
m)))))
(defun enable-hashtable-literal ()
(set-dispatch-macro-character
#\# #\{ #'|#{-reader|)
#\# #\{ #'|#{-reader|))
(defun sethash (k v m)
"Convenience notation for setting a value in a hash table."