I'm trying to write an Annotated Predicate Calculus (APC) manager. Fundamental units in this manager are called selectors and have the structure:
[<var> <op> <val>]
For example, [color = red], [size >= 35], [age IN 20..40]
With Set-Macro-Character I can get the Lisp reader to correctly parse a selector using:
Code: Select all
(set-macro-character #[
(lambda (stream char)
(let* ((lst (read-delimited-list #] stream t)))
(read-selector lst)))) ;; function read-selector handles the selector parsing, for example, suppose it just inverts the list...
(set-macro-character #]
(get-macro-character #)))
Code: Select all
CL-USER> '[a b c d]
(D C B A) <-- it displays with parenthesis instead of brackets
So I have two questions:
1) Is there a way, maybe using deftype and some output-configuration trick to make Lisp recognize selectors and display them correctly?
2) In any case, is it worthwhile doing the above instead of defining a CLOS model for the same task?
Thank you in advance for your comments...