[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "fall-through" generic function args plus &context

From: Stefan Monnier
Subject: Re: "fall-through" generic function args plus &context
Date: Tue, 27 Dec 2016 16:30:19 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

>> But currently cl-generic does not support this notion of "generic
>> function" quite the way CLOS does (for one our "generic functions"
>> objects are `defstruct` rather than `defclass` objects, and also
>> they're not callable so the function cell is yet different (a fairly
>> standard closure)).

> Thanks for the tips! Using fundamental-mode didn't work (at least not in
> the emacs-lisp buffer I tested it in),

Hmm... indeed we don't register fundamental-mode as a parent for
some reason.  I think either (&context (major-mode nil)) or (&context
(major-mode fundamental-mode)) or both should work.

> but the empty arg-list did, so that's sorted.

That's the better choice anyway (it's marginally more efficient).

> I haven't looked too hard at the specializer code, but if we can already
> dispatch on defstructs, it seems like it wouldn't be that hard to make
> something that dispatches on generics?

Yes, it shouldn't be too hard, but it still requires offering the
possibility to use a "child defstruct" for a given generic function
(currently, all generic function objects are deftruct of the same type,
so there's not much dispatch to do).
IOW implement the :generic-function-class arg to `cl-defgeneric` as well
as well as exposing the `cl--generic` type (i.e. renaming it) so users
can define child defstructs.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]