all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* EIEIO with lexical scoping
@ 2013-05-13 21:25 Stefan Monnier
  2013-05-14  0:00 ` Eric M. Ludlam
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2013-05-13 21:25 UTC (permalink / raw)
  To: Eric M. Ludlam; +Cc: emacs-devel

I'm trying to compile eieio.el using lexical-binding but am bumping into
a problem that requires too much internal knowledge of eieio for me.

I'm using the patch appended below for now, which seems to work to some
extent, but when I then try to compile CEDET using it, I get the
following backtrace:

Debugger entered--Lisp error: (invalid-slot-name "#<semanticdb-project-database default-cache-object>" tables)
  signal(invalid-slot-name ("#<semanticdb-project-database default-cache-object>" tables))
  eieio-default-superclass([object semanticdb-project-database default-cache-object unbound semanticdb-table nil nil] tables oref-default)
  apply(eieio-default-superclass ([object semanticdb-project-database default-cache-object unbound semanticdb-table nil nil] tables oref-default))
  eieio-generic-call-primary-only(slot-missing ([object semanticdb-project-database default-cache-object unbound semanticdb-table nil nil] tables oref-default))
  slot-missing([object semanticdb-project-database default-cache-object unbound semanticdb-table nil nil] tables oref-default)
  eieio-oref-default([object semanticdb-project-database default-cache-object unbound semanticdb-table nil nil] tables)
  eieio-set-defaults([object semanticdb-project-database default-cache-object unbound semanticdb-table nil nil] t)
  eieio-defclass(semanticdb-project-database (eieio-instance-tracker) ((tracking-symbol :initform semanticdb-database-list) (reference-directory :type string :documentation "Directory this database refers to.\nWhen a cache directory is specified, then this refers to the directory\nthis database contains symbols for.") (new-table-class :initform semanticdb-table :type class :documentation "New tables created for this database are of this class.") (cache :type list :initform nil :documentation "List of cache information for tools.\nAny particular tool can cache data to a database at runtime\nwith `semanticdb-cache-get'.\n\nUsing a semanticdb cache does not save any information to a file,\nso your cache will need to be recalculated at runtime.\n\nNote: This index will not be saved in a persistent file.") (tables :initarg :tables :type semanticdb-abstract-table-list :accessor semanticdb-get-database-tables :protection :protected :documentation "List of `semantic-db-table' objects.")) ("Database of file tables."))
  (progn (eieio-defclass 'semanticdb-project-database '(eieio-instance-tracker) '((tracking-symbol :initform semanticdb-database-list) (reference-directory :type string :documentation "Directory this database refers to.\nWhen a cache directory is specified, then this refers to the directory\nthis database contains symbols for.") (new-table-class :initform semanticdb-table :type class :documentation "New tables created for this database are of this class.") (cache :type list :initform nil :documentation "List of cache information for tools.\nAny particular tool can cache data to a database at runtime\nwith `semanticdb-cache-get'.\n\nUsing a semanticdb cache does not save any information to a file,\nso your cache will need to be recalculated at runtime.\n\nNote: This index will not be saved in a persistent file.") (tables :initarg :tables :type semanticdb-abstract-table-list :accessor semanticdb-get-database-tables :protection :protected :documentation "List of `semantic-db-table' objects.")) '("Database of file tables.")))
  eval((progn (eieio-defclass 'semanticdb-project-database '(eieio-instance-tracker) '((tracking-symbol :initform semanticdb-database-list) (reference-directory :type string :documentation "Directory this database refers to.\nWhen a cache directory is specified, then this refers to the directory\nthis database contains symbols for.") (new-table-class :initform semanticdb-table :type class :documentation "New tables created for this database are of this class.") (cache :type list :initform nil :documentation "List of cache information for tools.\nAny particular tool can cache data to a database at runtime\nwith `semanticdb-cache-get'.\n\nUsing a semanticdb cache does not save any information to a file,\nso your cache will need to be recalculated at runtime.\n\nNote: This index will not be saved in a persistent file.") (tables :initarg :tables :type semanticdb-abstract-table-list :accessor semanticdb-get-database-tables :protection :protected :documentation "List of `semantic-db-table' objects.")) '("Database of file tables."))) nil)
  #[128 "\301\302\303B\b\"D\207" [lexical-binding quote eval progn] 5 "\n\n(fn &rest BODY)"]((eieio-defclass 'semanticdb-project-database '(eieio-instance-tracker) '((tracking-symbol :initform semanticdb-database-list) (reference-directory :type string :documentation "Directory this database refers to.\nWhen a cache directory is specified, then this refers to the directory\nthis database contains symbols for.") (new-table-class :initform semanticdb-table :type class :documentation "New tables created for this database are of this class.") (cache :type list :initform nil :documentation "List of cache information for tools.\nAny particular tool can cache data to a database at runtime\nwith `semanticdb-cache-get'.\n\nUsing a semanticdb cache does not save any information to a file,\nso your cache will need to be recalculated at runtime.\n\nNote: This index will not be saved in a persistent file.") (tables :initarg :tables :type semanticdb-abstract-table-list :accessor semanticdb-get-database-tables :protection :protected :documentation "List of `semantic-db-table' objects.")) '("Database of file tables.")))
  (eval-and-compile (eieio-defclass 'semanticdb-project-database '(eieio-instance-tracker) '((tracking-symbol :initform semanticdb-database-list) (reference-directory :type string :documentation "Directory this database refers to.\nWhen a cache directory is specified, then this refers to the directory\nthis database contains symbols for.") (new-table-class :initform semanticdb-table :type class :documentation "New tables created for this database are of this class.") (cache :type list :initform nil :documentation "List of cache information for tools.\nAny particular tool can cache data to a database at runtime\nwith `semanticdb-cache-get'.\n\nUsing a semanticdb cache does not save any information to a file,\nso your cache will need to be recalculated at runtime.\n\nNote: This index will not be saved in a persistent file.") (tables :initarg :tables :type semanticdb-abstract-table-list :accessor semanticdb-get-database-tables :protection :protected :documentation "List of `semantic-db-table' objects.")) '("Database of file tables.")))
  (defclass semanticdb-project-database (eieio-instance-tracker) ((tracking-symbol :initform semanticdb-database-list) (reference-directory :type string :documentation "Directory this database refers to.\nWhen a cache directory is specified, then this refers to the directory\nthis database contains symbols for.") (new-table-class :initform semanticdb-table :type class :documentation "New tables created for this database are of this class.") (cache :type list :initform nil :documentation "List of cache information for tools.\nAny particular tool can cache data to a database at runtime\nwith `semanticdb-cache-get'.\n\nUsing a semanticdb cache does not save any information to a file,\nso your cache will need to be recalculated at runtime.\n\nNote: This index will not be saved in a persistent file.") (tables :initarg :tables :type semanticdb-abstract-table-list :accessor semanticdb-get-database-tables :protection :protected :documentation "List of `semantic-db-table' objects.")) "Database of file tables.")
  eval-buffer(#<buffer  *load*-733491> nil "/home/monnier/src/emacs/work/lisp/cedet/semantic/db.el" nil t)  ; Reading at buffer position 12358662
  load-with-code-conversion("/home/monnier/src/emacs/work/lisp/cedet/semantic/db.el" "/home/monnier/src/emacs/work/lisp/cedet/semantic/db.el" nil t)
  require(semantic/db)
  eval-buffer(#<buffer  *load*-379672> nil "/home/monnier/src/emacs/work/lisp/cedet/semantic/db-find.el" nil t)  ; Reading at buffer position 12350271
  load-with-code-conversion("/home/monnier/src/emacs/work/lisp/cedet/semantic/db-find.el" "/home/monnier/src/emacs/work/lisp/cedet/semantic/db-find.el" nil t)
  require(semantic/db-find)
  (progn (require 'semantic/db-find) (require 'semantic/find))
  eval((progn (require 'semantic/db-find) (require 'semantic/find)) nil)
  #[128 "\301\302\303B\b\"D\207" [lexical-binding quote eval progn] 5 "\n\n(fn &rest BODY)"]((require 'semantic/db-find) (require 'semantic/find))
  (eval-when-compile (require 'semantic/db-find) (require 'semantic/find))
  eval-buffer(#<buffer  *load*-7472> nil "/home/monnier/src/emacs/work/lisp/cedet/semantic/util.el" nil t)  ; Reading at buffer position 12346843
  load-with-code-conversion("/home/monnier/src/emacs/work/lisp/cedet/semantic/util.el" "/home/monnier/src/emacs/work/lisp/cedet/semantic/util.el" nil t)
  require(semantic/util)
  eval-buffer(#<buffer  *load*-252040> nil "/home/monnier/src/emacs/work/lisp/cedet/semantic.el" nil t)  ; Reading at buffer position 12395975
  load-with-code-conversion("/home/monnier/src/emacs/work/lisp/cedet/semantic.el" "/home/monnier/src/emacs/work/lisp/cedet/semantic.el" nil t)
  require(semantic)
  eval-buffer(#<buffer  *load*> nil "/home/monnier/src/emacs/work/lisp/cedet/semantic/util.el" nil t)  ; Reading at buffer position 12346651
  load-with-code-conversion("/home/monnier/src/emacs/work/lisp/cedet/semantic/util.el" "/home/monnier/src/emacs/work/lisp/cedet/semantic/util.el" nil t)
  require(semantic/util)
  apply(require semantic/util)
  byte-compile-file-form-require((require 'semantic/util))
  byte-compile-file-form((require 'semantic/util))
  byte-compile-toplevel-file-form((require 'semantic/util))
  #[0 "r\300q\210	\203\0\306	\n\"\210eb\210\307\310\307w\210\311\312!\203\"\313y\210\202\0m\204B`\f\307\x13\314\300!\x13\2039\315\316!\210\317!)\266\202\0\320 \210d\321 )\210	\205Wr\nq\210\322	!)\207" [#<buffer  *Compiler Input*> byte-compile-current-file byte-compile--outbuffer byte-compile-unresolved-functions byte-compile-read-position byte-compile-last-position byte-compile-insert-header nil " 	\n\f" looking-at ";" 1 read byte-compile-warn "!! The file uses old-style backquotes !!\nThis functionality has been obsolete for more than 10 years already\nand will be removed soon.  See (elisp)Backquote in the manual." byte-compile-toplevel-file-form byte-compile-flush-pending byte-compile-warn-about-unresolved-functions byte-compile-fix-header old-style-backquotes] 3 "\n\n(fn)"]()
  byte-compile-from-buffer(#<buffer  *Compiler Input*>)
  byte-compile-file("/home/monnier/src/emacs/work/lisp/cedet/semantic.el")

Can you help me figure out what's going on?


        Stefan


=== modified file 'lisp/emacs-lisp/eieio.el'
--- lisp/emacs-lisp/eieio.el	2013-02-27 04:09:50 +0000
+++ lisp/emacs-lisp/eieio.el	2013-05-13 21:22:02 +0000
@@ -1,4 +1,4 @@
-;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects
+;;; eieio.el --- Enhanced Implementation of Emacs Interpreted Objects  -*- lexical-binding:t -*-
 ;;;              or maybe Eric's Implementation of Emacs Interpreted Objects
 
 ;; Copyright (C) 1995-1996, 1998-2013 Free Software Foundation, Inc.
@@ -193,32 +193,31 @@
   ;; No check: If eieio gets this far, it's probably been checked already.
   `(get ,class 'eieio-class-definition))
 
-(defmacro class-p (class)
+(defsubst class-p (class)
   "Return t if CLASS is a valid class vector.
 CLASS is a symbol."
   ;; this new method is faster since it doesn't waste time checking lots of
   ;; things.
-  `(condition-case nil
-       (eq (aref (class-v ,class) 0) 'defclass)
+  (condition-case nil
+      (eq (aref (class-v class) 0) 'defclass)
      (error nil)))
 
-(defmacro eieio-object-p (obj)
+(defsubst eieio-object-p (obj)
   "Return non-nil if OBJ is an EIEIO object."
-  `(let ((tobj ,obj))
-     (and (vectorp tobj)
-          (eq (aref tobj 0) 'object)
-          (class-p (eieio--object-class tobj)))))
+  (and (vectorp obj)
+       (eq (aref obj 0) 'object)
+       (class-p (eieio--object-class obj))))
 (defalias 'object-p 'eieio-object-p)
 
 (defmacro class-constructor (class)
   "Return the symbol representing the constructor of CLASS."
   `(eieio--class-symbol (class-v ,class)))
 
-(defmacro generic-p (method)
+(defsubst generic-p (method)
   "Return t if symbol METHOD is a generic function.
 Only methods have the symbol `eieio-method-obarray' as a property
 \(which contains a list of all bindings to that method type.)"
-  `(and (fboundp ,method) (get ,method 'eieio-method-obarray)))
+  (and (fboundp method) (get method 'eieio-method-obarray)))
 
 (defun generic-primary-only-p (method)
   "Return t if symbol METHOD is a generic function with only primary methods.
@@ -261,10 +260,10 @@
 Return nil if that option doesn't exist."
   `(class-option-assoc (eieio--class-options (class-v ,class)) ',option))
 
-(defmacro class-abstract-p (class)
+(defsubst class-abstract-p (class)
   "Return non-nil if CLASS is abstract.
 Abstract classes cannot be instantiated."
-  `(class-option ,class :abstract))
+  (class-option class :abstract))
 
 (defmacro class-method-invocation-order (class)
   "Return the invocation order of CLASS.
@@ -501,7 +500,7 @@
 		    (setf (eieio--class-children (class-v (car pname)))
 			  (cons cname (eieio--class-children (class-v (car pname))))))
 		  ;; Get custom groups, and store them into our local copy.
-		  (mapc (lambda (g) (add-to-list 'groups g))
+		  (mapc (lambda (g) (pushnew g groups :test #'equal))
 			(class-option (car pname) :custom-groups))
 		  ;; save parent in child
 		  (setf (eieio--class-parent newc) (cons (car pname) (eieio--class-parent newc))))
@@ -680,7 +679,7 @@
 			     prot initarg alloc 'defaultoverride skip-nil)
 
 	;; We need to id the group, and store them in a group list attribute.
-	(mapc (lambda (cg) (add-to-list 'groups cg)) customg)
+	(mapc (lambda (cg) (pushnew cg groups :test #'equal)) customg)
 
 	;; Anyone can have an accessor function.  This creates a function
 	;; of the specified name, and also performs a `defsetf' if applicable
@@ -824,7 +823,7 @@
 
     ;; We have a list of custom groups.  Store them into the options.
     (let ((g (class-option-assoc options :custom-groups)))
-      (mapc (lambda (cg) (add-to-list 'g cg)) groups)
+      (mapc (lambda (cg) (pushnew cg g :test #'equal)) groups)
       (if (memq :custom-groups options)
 	  (setcar (cdr (memq :custom-groups options)) g)
 	(setq options (cons :custom-groups (cons g options)))))
@@ -856,10 +855,10 @@
 (defun eieio-perform-slot-validation-for-default (slot spec value skipnil)
   "For SLOT, signal if SPEC does not match VALUE.
 If SKIPNIL is non-nil, then if VALUE is nil return t instead."
-  (if (and (not (eieio-eval-default-p value))
-	   (not eieio-skip-typecheck)
-	   (not (and skipnil (null value)))
-	   (not (eieio-perform-slot-validation spec value)))
+  (if (not (or (eieio-eval-default-p value)
+	       eieio-skip-typecheck
+	       (and skipnil (null value))
+	       (eieio-perform-slot-validation spec value)))
       (signal 'invalid-slot-type (list slot spec value))))
 
 (defun eieio-add-new-slot (newc a d doc type cust label custg print prot init alloc
@@ -1425,10 +1424,8 @@
 	    (t
 	     (let* ((name (symbol-name type))
 		    (namep (intern (concat name "p"))))
-	       (if (fboundp namep)
-		   (funcall `(lambda () (,namep val)))
-		 (funcall `(lambda ()
-			     (,(intern (concat name "-p")) val)))))))
+	       (funcall (if (fboundp namep) namep (intern (concat name "-p")))
+                        val))))
     (cond ((get (car type) 'cl-deftype-handler)
 	   (eieio--typep val (apply (get (car type) 'cl-deftype-handler)
 				    (cdr type))))
@@ -1450,7 +1447,7 @@
 	  ((memq (car type) '(member member*))
 	   (memql val (cdr type)))
 	  ((eq (car type) 'satisfies)
-	   (funcall `(lambda () (,(cadr type) val))))
+	   (funcall (cadr type) val))
 	  (t (error "Bad type spec: %s" type)))))
 
 (defun eieio-perform-slot-validation (spec value)
@@ -1799,9 +1796,9 @@
   `(car (eieio-class-parents ,class)))
 (define-obsolete-function-alias 'class-parent #'eieio-class-parent "24.4")
 
-(defmacro same-class-fast-p (obj class)
+(defsubst same-class-fast-p (obj class)
   "Return t if OBJ is of class-type CLASS with no error checking."
-  `(eq (eieio--object-class ,obj) ,class))
+  (eq (eieio--object-class obj) class))
 
 (defun same-class-p (obj class) "Return t if OBJ is of class-type CLASS."
   (eieio--check-type class-p class)
@@ -2459,11 +2456,10 @@
 		   buffer-file-name))
 	  loc)
       (when fname
-	(when (string-match "\\.elc$" fname)
+	(when (string-match "\\.elc\\'" fname)
 	  (setq fname (substring fname 0 (1- (length fname)))))
 	(setq loc (get method-name 'method-locations))
-	(add-to-list 'loc
-		     (list class fname))
+	(pushnew (list class fname) loc :test #'equal)
 	(put method-name 'method-locations loc)))
     ;; Now optimize the entire obarray
     (if (< key method-num-lists)




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

end of thread, other threads:[~2013-06-03 19:35 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-13 21:25 EIEIO with lexical scoping Stefan Monnier
2013-05-14  0:00 ` Eric M. Ludlam
2013-05-14  1:57   ` Eric M. Ludlam
2013-05-14  2:13   ` Stefan Monnier
2013-05-14 12:42     ` Stefan Monnier
2013-05-14 20:25     ` David Engster
2013-05-14 22:32       ` Stefan Monnier
2013-06-02 16:45       ` David Engster
2013-06-02 20:47         ` Stefan Monnier
2013-06-03 15:23           ` David Engster
2013-06-03 18:35             ` Glenn Morris
2013-06-03 19:35               ` Stefan Monnier

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.