One annoyance of ensure-generic-function-using-class

Pascal Costanza pc at p-cos.net
Wed Dec 27 12:27:13 UTC 2017


Hi,

> On 27 Dec 2017, at 12:50, Didier Verna <didier at lrde.epita.fr> wrote:
> 
> 
>  Hello,
> 
> there is something annoying with
> ensure-generic-function-using-class. The MOP specifies that if the
> :generic-function-class option is not provided, it defaults to
> standard-generic-function. While this makes perfect sense when the
> generic function doesn't already exist, it seems to also apply when it
> does.
> 
> As a result, if you want to call ensure-generic-function on an existing
> generic function using a different meta-class, for instance like this:
> 
> (ensure-generic-function gf-name :generic-function-class (class-of gf))
> 
> 
> This is a bit annoying, and I don't understand the rationale behind
> this, if there's one. Why not defaulting to the existing generic
> function's meta-class?


ensure-generic-function is the functional version of the defgeneric macro, and is supposed to behave the same way. If you don’t pass the :generic-function-class option to the defgeneric macro, it will also default to standard-generic-function, no matter what the previous definition of the generic function was.

If you want to change only one or a few aspects of a generic function (or metaobjects in general), you are supposed to call reinitialize-instance, which leaves all properties for which no keywords are passed unchanged.

Pascal

--
Pascal Costanza


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20171227/9b9c5eb9/attachment.html>


More information about the pro mailing list