Funcallable Standard Objects?
I have been experimenting on/off with Funcallable-Standard-Class metaclass and the resulting Funcallable-Standard-Objects.I notice a peculiar asymmetry, wherein you must assign the functional behavior in an Initialize-Instance method using CLOS:SET-FUNCALLABLE-INSTANCE-FUNCTION, yet there is no corresponding method to retrieve the functional behavior of the instance once constructed.
Does anyone know or understand the reasoning behind this asymmetry. It has the feel of an intentional decision, but I’m puzzled about the language theoretic reasons behind it.
In order to retain visibility of the function, I have resorted to making an instance slot to hold the function, then using an indirect dispatch function in the initialize-instance method:
(defclass standard-handler ()
((handler-fn :accessor handler-fn :initarg :fn))
(:metaclass clos:funcallable-standard-class))
;; -----------------------------------------
(defmethod initialize-instance :after ((h standard-handler) &key &allow-other-keys)
(clos:set-funcallable-instance-function h (lambda (&rest args)
(apply (handler-fn h) args))))
- DM