Re:dspec:define-dspec-alias
The dsepc system was really unclear for me. After a lot of time, I finally
found a solution for the problem I had : find the source of forms produced
by a macro witch can define functions OR methods.
The code is below (if there is any interest for this question).
Best regards
Denis
;def-foo define a function OR a method depending of the argument method-p
(defmacro def-foo (name method-p args &body body)
`,(if method-p
`(defmethod ,name ,args ,@body)
`(defun ,name ,args ,@body)))
;I define one function and one method. After that, using find-source, I can
find the buffer but NOT the correct position of the form in the buffer
(def-foo foo-function nil (x) :function)
(def-foo foo-method t ((x number)) :method)
;I need to define the dspec-alias (here, the arglist is the arglist of the
;function or method defined, not the one of def-foo)
(dspec:define-dspec-alias def-foo (name &rest args)
(if (clos::generic-function-p (symbol-function (if (listp name) (cadr
name) name)))
`(defmethod ,name ,@args)
name))
;And I need to define a form parser (here, the arglist is the arglist of
;def-foo). The form returned by the form-parser can be just the name
;- foo-function - for function, or a list with name and specializers
; - (defmethod foo-method (number)) - for the method. The name can also be
;a setf form)
(dspec:define-form-parser def-foo (name method-p args)
(declare (ignore def-foo))
(if method-p
`(defmethod ,name ,(clos:extract-specializer-names args))
name))
;The forms produced by define-dspec-alias and define-form-parser are
;evaluated when using find-source (in fact when pull-down some menu of the
LW IDE on my MAC), so it can be defined after the other forms and redefined
;anytime without having to recompile or reload the defined functions or
;methods.
-------------------------------------------------------
Denis Pousseur
70 rue de Wansijn
1180 Bruxelles, Belgique
Tel : 32 (0)2 219 31 09
Mail : denis.pousseur@gmail.com
-------------------------------------------------------