GNU bug report logs -
#9313
24.0.50; Emacs 24 cannot load byte-compiled code from Emacs 23.3 when using EIEIO's defmethod
Previous Next
Reported by: David Engster <deng <at> randomsample.de>
Date: Wed, 17 Aug 2011 15:55:01 UTC
Severity: normal
Found in version 24.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 9313 in the body.
You can then email your comments to 9313 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9313
; Package
emacs
.
(Wed, 17 Aug 2011 15:55:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
David Engster <deng <at> randomsample.de>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 17 Aug 2011 15:55:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
This is a very late followup to an older message from emacs-devel,
regarding the issue that Emacs24 after the lexbind merge cannot run
byte-compiled code from Emacs23.3 if that is using EIEIO's 'defmethod':
http://thread.gmane.org/gmane.emacs.devel/138030/focus=78338
In that message Stefan Monnier says that this is considered a bug, so
I'm writing this report. Also, this issue is popping up more frequently
now as people are migrating to Emacs24-bzr, but still have compiled Gnus
or CEDET sources with Emacs23, so I think this should be fixed before a
release.
Here's a recipe:
* Create a file ~/eieio-test/eieio-test.el with the following contents:
(require 'eieio)
(defclass someclass ()
((astring :initarg :astring
:initform ""))
"Some test class.")
(defmethod somemethod ((arg someclass))
"Some method."
(message "Somemethod called."))
(provide 'eieio-test)
* Byte-compile the file using Emacs 23.3:
emacs23 --batch -f batch-byte-compile eieio-test.el
* Load Emacs24-bzr with
emacs24 -Q -L ~/eieio-test
and evaluate
(require 'eieio-test)
* The following backtrace will appear:
Debugger entered--Lisp error: (void-function eieio-defmethod)
(eieio-defmethod (quote somemethod) (quote (((arg someclass)) #[(arg) "\300\301!\207" [message "Somemethod called."] 2 "Some method."])))
require(eieio-test)
eval((require (quote eieio-test)) nil)
* Note that the following setups work:
- Byte compile with Emacs23, require with Emacs23
- Byte compile with Emacs24, require with Emacs24
- Require uncompiled el-file.
* This issue is occuring since the lexbind merge.
Cheers,
David
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9313
; Package
emacs
.
(Mon, 22 Aug 2011 21:50:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 9313 <at> debbugs.gnu.org (full text, mbox):
> This is a very late followup to an older message from emacs-devel,
> regarding the issue that Emacs24 after the lexbind merge cannot run
> byte-compiled code from Emacs23.3 if that is using EIEIO's 'defmethod':
Does the patch below fix the problem for you?
Stefan
=== modified file 'lisp/emacs-lisp/eieio.el'
--- lisp/emacs-lisp/eieio.el 2011-05-23 00:39:25 +0000
+++ lisp/emacs-lisp/eieio.el 2011-08-22 21:46:05 +0000
@@ -2864,6 +2864,106 @@
)
+;;; Obsolete backward compatibility functions.
+;; Used to run byte-code compiled with Emacs-23.
+
+(defun eieio-defmethod (method args)
+ "Work part of the `defmethod' macro defining METHOD with ARGS."
+ (let ((key nil) (body nil) (firstarg nil) (argfix nil) (argclass nil) loopa)
+ ;; find optional keys
+ (setq key
+ (cond ((or (eq ':BEFORE (car args))
+ (eq ':before (car args)))
+ (setq args (cdr args))
+ method-before)
+ ((or (eq ':AFTER (car args))
+ (eq ':after (car args)))
+ (setq args (cdr args))
+ method-after)
+ ((or (eq ':PRIMARY (car args))
+ (eq ':primary (car args)))
+ (setq args (cdr args))
+ method-primary)
+ ((or (eq ':STATIC (car args))
+ (eq ':static (car args)))
+ (setq args (cdr args))
+ method-static)
+ ;; Primary key
+ (t method-primary)))
+ ;; get body, and fix contents of args to be the arguments of the fn.
+ (setq body (cdr args)
+ args (car args))
+ (setq loopa args)
+ ;; Create a fixed version of the arguments
+ (while loopa
+ (setq argfix (cons (if (listp (car loopa)) (car (car loopa)) (car loopa))
+ argfix))
+ (setq loopa (cdr loopa)))
+ ;; make sure there is a generic
+ (eieio-defgeneric
+ method
+ (if (stringp (car body))
+ (car body) (format "Generically created method `%s'." method)))
+ ;; create symbol for property to bind to. If the first arg is of
+ ;; the form (varname vartype) and `vartype' is a class, then
+ ;; that class will be the type symbol. If not, then it will fall
+ ;; under the type `primary' which is a non-specific calling of the
+ ;; function.
+ (setq firstarg (car args))
+ (if (listp firstarg)
+ (progn
+ (setq argclass (nth 1 firstarg))
+ (if (not (class-p argclass))
+ (error "Unknown class type %s in method parameters"
+ (nth 1 firstarg))))
+ (if (= key -1)
+ (signal 'wrong-type-argument (list :static 'non-class-arg)))
+ ;; generics are higher
+ (setq key (eieio-specialized-key-to-generic-key key)))
+ ;; Put this lambda into the symbol so we can find it
+ (if (byte-code-function-p (car-safe body))
+ (eieiomt-add method (car-safe body) key argclass)
+ (eieiomt-add method (append (list 'lambda (reverse argfix)) body)
+ key argclass))
+ )
+
+ (when eieio-optimize-primary-methods-flag
+ ;; Optimizing step:
+ ;;
+ ;; If this method, after this setup, only has primary methods, then
+ ;; we can setup the generic that way.
+ (if (generic-primary-only-p method)
+ ;; If there is only one primary method, then we can go one more
+ ;; optimization step.
+ (if (generic-primary-only-one-p method)
+ (eieio-defgeneric-reset-generic-form-primary-only-one method)
+ (eieio-defgeneric-reset-generic-form-primary-only method))
+ (eieio-defgeneric-reset-generic-form method)))
+
+ method)
+(make-obsolete 'eieio-defmethod 'eieio--defmethod "24.1")
+
+(defun eieio-defgeneric (method doc-string)
+ "Engine part to `defgeneric' macro defining METHOD with DOC-STRING."
+ (if (and (fboundp method) (not (generic-p method))
+ (or (byte-code-function-p (symbol-function method))
+ (not (eq 'autoload (car (symbol-function method)))))
+ )
+ (error "You cannot create a generic/method over an existing symbol: %s"
+ method))
+ ;; Don't do this over and over.
+ (unless (fboundp 'method)
+ ;; This defun tells emacs where the first definition of this
+ ;; method is defined.
+ `(defun ,method nil)
+ ;; Make sure the method tables are installed.
+ (eieiomt-install method)
+ ;; Apply the actual body of this function.
+ (fset method (eieio-defgeneric-form method doc-string))
+ ;; Return the method
+ 'method))
+(make-obsolete 'eieio-defgeneric nil "24.1")
+
;;; Interfacing with edebug
;;
(defun eieio-edebug-prin1-to-string (object &optional noescape)
Information forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#9313
; Package
emacs
.
(Tue, 23 Aug 2011 16:17:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 9313 <at> debbugs.gnu.org (full text, mbox):
Stefan Monnier writes:
>> This is a very late followup to an older message from emacs-devel,
>> regarding the issue that Emacs24 after the lexbind merge cannot run
>> byte-compiled code from Emacs23.3 if that is using EIEIO's 'defmethod':
>
> Does the patch below fix the problem for you?
Yes.
Thanks,
David
Reply sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
You have taken responsibility.
(Tue, 23 Aug 2011 18:57:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
David Engster <deng <at> randomsample.de>
:
bug acknowledged by developer.
(Tue, 23 Aug 2011 18:57:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 9313-done <at> debbugs.gnu.org (full text, mbox):
>>> This is a very late followup to an older message from emacs-devel,
>>> regarding the issue that Emacs24 after the lexbind merge cannot run
>>> byte-compiled code from Emacs23.3 if that is using EIEIO's 'defmethod':
>> Does the patch below fix the problem for you?
> Yes.
Thanks, installed,
Stefan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 21 Sep 2011 11:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 13 years and 277 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.