Open ruricolist opened 4 years ago
This can be worked around with Eclector. Proof of concept:
(in-package :serapeum-user)
(defclass namespaced-keyword-client () ())
(defmethod eclector.reader:interpret-token ((client namespaced-keyword-client)
input-stream
token
escape-ranges)
(let* (namespaced?
(token
(handler-bind ((eclector.reader:two-package-markers-must-not-be-first
(lambda (e) (declare (ignore e))
(setf namespaced? t)
(invoke-restart 'eclector.reader:recover))))
(call-next-method))))
(if namespaced?
(intern (string+ (package-name *package*) "/"
(symbol-name token))
:keyword)
token)))
(let ((eclector.reader:*client* (make 'namespaced-keyword-client)))
(eclector.reader:read-from-string "::keyword"))
Before electing Eclector, however, I need to be sure it can handle Clojure quasiquotation.
The
::
syntax for namespaced keywords does not work, and it does not appear it can be made to work within the limits of the Lisp reader.Explicitly namespaced keywords still work; it is only the
::
shorthand that doesn't work.Namespaced keywords do not appear to be widely used, however.