Need a style advice
Hello,
In the :default-initargs section of a class, I would like to specify a list of mappings between strings and functions. Something like :
(defclass foo (bar)
()
(:default-initargs
:bar-mappings '(("hello" #'say-hello)
("world" #'see-the-world))))
Where :bar-mappings would be later processed as:
(defmethod initialize-instance :after ((self bar) &key bar-mappings)
(loop :for mapping :in bar-mappings
:do (apply #'bar-register-mapping mapping)))
But that does not work because #'hello-function – being in a quoted list – is parsed as (FUNCTION HELLO-FUNCTION).
Other options for writing the definition of foo:
1. Ugly
(defclass foo (bar)
()
(:default-initargs
:bar-mappings `(("hello" ,#'say-hello)
("world" ,#'see-the-world))))
2. Ugly too
(defclass foo (bar)
()
(:default-initargs
:bar-mappings (list (list "hello" #'say-hello)
(list "world" #'see-the-world))))
I am sure there is a third solution that I have overlooked.
Please share your ideas!
Best Regards,
Camille