jscl icon indicating copy to clipboard operation
jscl copied to clipboard

!ensure-generic-function refactoring

Open vlad-km opened this issue 3 years ago • 0 comments

`If function-name is a list it must be of the form (setf symbol).

If (fboundp function-name) is false, a new generic function is created.

If (fdefinition function-name) is a generic function, that generic function is modified.

If function-name names an ordinary function, a macro, or a special operator, an error is signaled. `

In this artifact (the current implementation of CLOS), when redefining the GF (if it exists), the existing descriptor is returned and the redefinition is not performed.

CL-USER> (defgeneric stub (a b c))
#<standard-generic-function STUB>
CL-USER> (defmethod stub (a b c) 'stub-arity-3)
#<standard-method STUB(A B C)>
CL-USER> (defgeneric stub (a))
#<standard-generic-function STUB>
CL-USER> (stub 1)
ERROR: Too few arguments to generic function #<standard-generic-function STUB>.
CL-USER> 

It would be nice to add an option method-descriptor.

`The method-description arguments define methods that will be associated with the generic function.

The method-qualifier and specialized-lambda-list arguments in a method description are the same as for defmethod.`

(defun !ensure-generic-function (function-name &rest all-keys)

vlad-km avatar Feb 11 '22 19:02 vlad-km