From: Vitalie Spinu <spinuvit@gmail.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 20420@debbugs.gnu.org
Subject: bug#20420: 25.0.50; eieio methods with optional arguments now fail
Date: Sat, 25 Apr 2015 01:35:17 +0200 [thread overview]
Message-ID: <878udhp0ay.fsf@gmail.com> (raw)
In-Reply-To: <jwvlhhhb6r9.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Fri, 24 Apr 2015 16:42:01 -0400")
>>> Stefan Monnier on Fri, 24 Apr 2015 16:42:01 -0400 wrote:
>> (defgeneric xx (&optional a b))
>> (defmethod xx ()
>> (message "default"))
> Hmmm... I think this really only worked by accident and wasn't
> explicitly supported by Emacs-24's doc. And adding support for such
> degenerate methods might not be straightforward in eieio-compat.el, so
> I'm wondering where you've seen such use, to see how important it is to
> provide that level of backward compatibility.
I was using function xx that, when called with no arguments, dispatched
methods with the same name on a local object in the current buffer.
I think this pattern is very general. Especially now with the new
cl-defmethod which supports (eql ...) dispatch. A common pattern would
be to dispatch a method on major-mode or other local variable by simply
defining the dispatcher with the same name and no arguments. In this
sense it's a partial generalization of the mode-local.el.
As we are on this topic how about allowing for implicit dispatch on the
arbitrary context? I mean something along the following lines:
(defun eq-major-mode (mode) (eq mode major-mode))
(defgeneric foo ((implicit eq-major-mode) arg1 arg2) ...)
(defmethod foo ('emacs-lisp-mode arg1 arg2) ...)
The `foo` then should be called only as (foo arg1 arg2) and the dispatch
is done implicitly by (eq 'emacs-lisp-mode major-mode).
A shortcut for a common user case might look like:
(defgeneric foo ((eql major-mode) arg1 arg2) ...)
to mean
(defgeneric foo ((implicit (lambda (obj) (eql major-mode))) arg1 arg2) ...)
This pattern would be a powerful generalization of mode-local.el and
would essentially obsolete classic emacs dispatch mechanism as in
(setq-local indent-line-function xxx-mode-indent-line).
Vitalie
next prev parent reply other threads:[~2015-04-24 23:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-24 19:28 bug#20420: 25.0.50; eieio methods with optional arguments now fail Vitalie Spinu
2015-04-24 20:42 ` Stefan Monnier
2015-04-24 23:35 ` Vitalie Spinu [this message]
2015-04-25 14:41 ` Stefan Monnier
2015-04-25 18:25 ` Vitalie Spinu
2015-04-26 4:02 ` Stefan Monnier
2015-04-26 12:00 ` Vitalie Spinu
2015-04-27 4:43 ` Stefan Monnier
2015-05-12 4:19 ` Stefan Monnier
2015-05-12 14:23 ` Vitalie Spinu
2016-05-14 23:01 ` Dmitry Gutov
2016-05-15 1:55 ` 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=878udhp0ay.fsf@gmail.com \
--to=spinuvit@gmail.com \
--cc=20420@debbugs.gnu.org \
--cc=monnier@IRO.UMontreal.CA \
/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.