[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20420: 25.0.50; eieio methods with optional arguments now fail
From: |
Vitalie Spinu |
Subject: |
bug#20420: 25.0.50; eieio methods with optional arguments now fail |
Date: |
Sat, 25 Apr 2015 01:35:17 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
>>> 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
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Vitalie Spinu, 2015/04/24
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Stefan Monnier, 2015/04/24
- bug#20420: 25.0.50; eieio methods with optional arguments now fail,
Vitalie Spinu <=
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Stefan Monnier, 2015/04/25
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Vitalie Spinu, 2015/04/25
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Stefan Monnier, 2015/04/26
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Vitalie Spinu, 2015/04/26
- bug#20420: 25.0.50; eieio methods with optional arguments now fail, Stefan Monnier, 2015/04/27