jscl-project / jscl

A Lisp-to-JavaScript compiler bootstrapped from Common Lisp

Home Page:https://jscl-project.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

!ensure-generic-function refactoring

vlad-km opened this issue · comments

commented

`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)