Hello,
I need to set a constant to be one instance of a class, but when I use:
Code:
Thanks in advance,
Jason
I need to set a constant to be one instance of a class, but when I use:
(defconstant +html-view+ (make-instance 'html-view)) the compile fails with "no such class 'html-view" (compiled in slime via load-system). I can fix this by slapping an eval-when around the defclass call, but this strikes me as pretty bizarre. Wouldn't defclass already be defined at load/compile time anyway? It also causes problems in SBCL as I then start getting the "constant redefined" error (presumably asdf is reloading the files several times for some reason, perhaps something to do with the dependancies).Code:
(defclass html-view ()
())
(defconstant +html-view+ (make-instance 'html-view))
(defgeneric render (component view))
(defmethod render ((component standard-object) (view html-view))
;...
)
(defun test-it ()
(render (make-instance 'web-page) +html-view+))
I suppose since what I'm doing here is using html (and xml) singletons I could just specialize on the meta-class instead but I don't like this for later when I start adding methods and slots of these views.Thanks in advance,
Jason