From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#9313: 24.0.50; Emacs 24 cannot load byte-compiled code from Emacs 23.3 when using EIEIO's defmethod Date: Mon, 22 Aug 2011 17:47:17 -0400 Message-ID: References: <87wreckpcs.fsf@engster.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1314049668 31010 80.91.229.12 (22 Aug 2011 21:47:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Aug 2011 21:47:48 +0000 (UTC) Cc: 9313@debbugs.gnu.org To: David Engster Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 22 23:47:44 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QvcLQ-0001fu-6O for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Aug 2011 23:47:44 +0200 Original-Received: from localhost ([::1]:40304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvcLP-0002DJ-NA for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Aug 2011 17:47:43 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvcLM-0002Bt-H9 for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2011 17:47:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QvcLL-0003HL-9R for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2011 17:47:40 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43400) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QvcLL-0003HH-6b for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2011 17:47:39 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QvcNe-0001e3-QS; Mon, 22 Aug 2011 17:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Aug 2011 21:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9313 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 9313-submit@debbugs.gnu.org id=B9313.13140497856296 (code B ref 9313); Mon, 22 Aug 2011 21:50:02 +0000 Original-Received: (at 9313) by debbugs.gnu.org; 22 Aug 2011 21:49:45 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QvcNN-0001dV-6R for submit@debbugs.gnu.org; Mon, 22 Aug 2011 17:49:45 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QvcNL-0001dO-0B for 9313@debbugs.gnu.org; Mon, 22 Aug 2011 17:49:44 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EABzOUk5Ld+HZ/2dsb2JhbABBqBV4gUABAQQBViMFCwsOJgcLFBgNJIgEtWyGSASfcYQ2 X-IronPort-AV: E=Sophos;i="4.68,265,1312171200"; d="scan'208";a="132239370" Original-Received: from 75-119-225-217.dsl.teksavvy.com (HELO ceviche.home) ([75.119.225.217]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 22 Aug 2011 17:47:17 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 7CFA96610A; Mon, 22 Aug 2011 17:47:17 -0400 (EDT) In-Reply-To: <87wreckpcs.fsf@engster.org> (David Engster's message of "Wed, 17 Aug 2011 17:52:03 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 22 Aug 2011 17:50:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 1) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:50228 Archived-At: > 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)