all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* EIEIO defmethod broken if symbol already bound?
@ 2013-05-18 15:10 Wilfred Hughes
  2013-05-19  9:45 ` Pierre Lorenzon
  0 siblings, 1 reply; 2+ messages in thread
From: Wilfred Hughes @ 2013-05-18 15:10 UTC (permalink / raw)
  To: help-gnu-emacs

Hi folks

I think this might be an Emacs bug, but I'm not familiar enough with EIEIO
to be certain. Suppose I want to assign a method foo to a class some-class:

(require 'eieio)

(defclass some-class ()
  ((bar :initform 42)))

(defmethod foo ((s some-class))
  1)

This works fine. However, if the function definition of foo is already
bound to t, it doesn't work:

(require 'eieio)

(defclass some-class ()
  ((bar :initform 42)))

(defalias 'foo 't)

(defmethod foo ((s some-class))
  1) ;; Debugger entered--Lisp error: (void-function foo)

I'm forced to set foo to a function (e.g. (defalias 'foo 'method)) before I
can use (defmethod foo ...). In fact, calling M-x describe-function <RET>
foo <RET> says 'file a bug report'.

Now, I know that (defalias 'foo 't) is silly thing to do. However, I
accidentally ended up in this state when hacking on some code.

Is this a legitimate bug? Emacs 24.2.1.

Thanks :)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: EIEIO defmethod broken if symbol already bound?
  2013-05-18 15:10 EIEIO defmethod broken if symbol already bound? Wilfred Hughes
@ 2013-05-19  9:45 ` Pierre Lorenzon
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre Lorenzon @ 2013-05-19  9:45 UTC (permalink / raw)
  To: me; +Cc: help-gnu-emacs


Hi,

In fact it is a question for cedet mailing lists. But I don't
really understand what you want to do.

I claim that it is not possible to define a method whose name
is the name of an existing emacs method :

(defun foo () ...) 
(defmethod foo () ...) Is not allowed. This is eieio policy. 

I suspect that (defalias foo ...) (defmethod foo ...) is not
permitied as well. In fact I suspect that the defmethod macro
or more certianly the defgeneric function will check the
function field of the symbol 'foo and if that one is not empty
or not set to something inheritable redefinition will be
prohibited. If I don't make a mistake defalias will also set
the function field of the symbol. The true mechanism is maybe a
little bit more sophisticated by usage of obarrays and hash
table but it works more or less as I said.

Surely (defmethod foo ((s class_1)) (defmethod foo ((s
class_2)) is allowed for inheritance (see usage of
call-next-method for this purpose.) 

Regards 

Pierre




From: Wilfred Hughes <me@wilfred.me.uk>
Subject: EIEIO defmethod broken if symbol already bound?
Date: Sat, 18 May 2013 16:10:36 +0100

> Hi folks
> 
> I think this might be an Emacs bug, but I'm not familiar enough with EIEIO
> to be certain. Suppose I want to assign a method foo to a class some-class:
> 
> (require 'eieio)
> 
> (defclass some-class ()
>   ((bar :initform 42)))
> 
> (defmethod foo ((s some-class))
>   1)
> 
> This works fine. However, if the function definition of foo is already
> bound to t, it doesn't work:
> 
> (require 'eieio)
> 
> (defclass some-class ()
>   ((bar :initform 42)))
> 
> (defalias 'foo 't)
> 
> (defmethod foo ((s some-class))
>   1) ;; Debugger entered--Lisp error: (void-function foo)
> 
> I'm forced to set foo to a function (e.g. (defalias 'foo 'method)) before I
> can use (defmethod foo ...). In fact, calling M-x describe-function <RET>
> foo <RET> says 'file a bug report'.
> 
> Now, I know that (defalias 'foo 't) is silly thing to do. However, I
> accidentally ended up in this state when hacking on some code.
> 
> Is this a legitimate bug? Emacs 24.2.1.
> 
> Thanks :)




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-19  9:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-18 15:10 EIEIO defmethod broken if symbol already bound? Wilfred Hughes
2013-05-19  9:45 ` Pierre Lorenzon

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.