GNU bug report logs -
#20420
25.0.50; eieio methods with optional arguments now fail
Previous Next
Reported by: Vitalie Spinu <spinuvit <at> gmail.com>
Date: Fri, 24 Apr 2015 19:29:01 UTC
Severity: normal
Found in version 25.0.50
Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Bug is archived. No further changes may be made.
Full log
Message #13 received at 20420 <at> debbugs.gnu.org (full text, mbox):
>>> 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
This bug report was last modified 9 years and 61 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.