all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: "fall-through" generic function args plus &context
Date: Tue, 27 Dec 2016 16:30:19 -0500	[thread overview]
Message-ID: <jwvmvfh83zy.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: 87y3z1z3pg.fsf@ericabrahamsen.net

>> 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.


        Stefan




  reply	other threads:[~2016-12-27 21:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-26 20:34 "fall-through" generic function args plus &context Eric Abrahamsen
2016-12-26 22:48 ` Eric Abrahamsen
2016-12-27  3:36   ` Stefan Monnier
2016-12-27 17:23     ` Eric Abrahamsen
2016-12-27 21:30       ` Stefan Monnier [this message]
2016-12-29  2:30         ` Eric Abrahamsen
2016-12-29 14:42           ` Stefan Monnier
2016-12-29 19:04             ` Eric Abrahamsen
2016-12-30 14:26               ` Stefan Monnier
2016-12-27  1:27 ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmvfh83zy.fsf-monnier+gmane.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.