Require explicit enabling of hash-table reader macro.
This commit is contained in:
parent
e14ffc164f
commit
45ef5eddb4
11
kutils.lisp
11
kutils.lisp
|
@ -30,7 +30,11 @@
|
||||||
(setq key-p t
|
(setq key-p t
|
||||||
v (read-from-string (finalise-read v)))
|
v (read-from-string (finalise-read v)))
|
||||||
(setf (gethash k m) 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)
|
(do ((prev (read-char stream) curr)
|
||||||
(curr (read-char stream) (read-char stream)))
|
(curr (read-char stream) (read-char stream)))
|
||||||
((and (char= prev #\}) (char= curr #\#)))
|
((and (char= prev #\}) (char= curr #\#)))
|
||||||
|
@ -39,14 +43,15 @@
|
||||||
(if key-p
|
(if key-p
|
||||||
(push prev k)
|
(push prev k)
|
||||||
(push prev v))))
|
(push prev v))))
|
||||||
(if (and (null v) (not (null k)))
|
(if (reading-complete-p)
|
||||||
(error "Mismatched key value pairs.")
|
(error "Mismatched key value pairs.")
|
||||||
(progn
|
(progn
|
||||||
(finalise-kv-pair)
|
(finalise-kv-pair)
|
||||||
m)))))
|
m)))))
|
||||||
|
|
||||||
|
(defun enable-hashtable-literal ()
|
||||||
(set-dispatch-macro-character
|
(set-dispatch-macro-character
|
||||||
#\# #\{ #'|#{-reader|)
|
#\# #\{ #'|#{-reader|))
|
||||||
|
|
||||||
(defun sethash (k v m)
|
(defun sethash (k v m)
|
||||||
"Convenience notation for setting a value in a hash table."
|
"Convenience notation for setting a value in a hash table."
|
||||||
|
|
Loading…
Reference in New Issue