summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/cl-preloaded.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2017-03-24 09:21:52 -0400
committerLars Brinkhoff <lars@nocrew.org>2017-04-04 08:23:46 +0200
commit2c68192c6b029bb839193c81cf2a16dad26305c6 (patch)
treeab9f36acd0dfc67d261d584949bd22fc8c262cd1 /lisp/emacs-lisp/cl-preloaded.el
parentb6738682ae16c71132c95cd87d48daf598fe89a9 (diff)
downloademacs-2c68192c6b029bb839193c81cf2a16dad26305c6.tar.gz
emacs-2c68192c6b029bb839193c81cf2a16dad26305c6.tar.bz2
emacs-2c68192c6b029bb839193c81cf2a16dad26305c6.zip
Backward compatibility with pre-existing struct instances.
* lisp/emacs-lisp/cl-lib.el (cl--old-struct-type-of): New function. (cl-old-struct-compat-mode): New minor mode. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Pass `record' to cl-struct-define to signal use of record objects. * lisp/emacs-lisp/cl-preloaded.el (cl--struct-get-class, cl-struct-define): Enable legacy defstruct compatibility. * test/lisp/emacs-lisp/cl-lib-tests.el (cl-lib-old-struct, old-struct): New tests. * doc/lispref/elisp.texi, doc/lispref/records.texi: Document `old-struct-compat'.
Diffstat (limited to 'lisp/emacs-lisp/cl-preloaded.el')
-rw-r--r--lisp/emacs-lisp/cl-preloaded.el6
1 files changed, 6 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
index 7432dd4978d..ab6354de7cd 100644
--- a/lisp/emacs-lisp/cl-preloaded.el
+++ b/lisp/emacs-lisp/cl-preloaded.el
@@ -110,6 +110,12 @@
;;;###autoload
(defun cl-struct-define (name docstring parent type named slots children-sym
tag print)
+ (unless type
+ ;; Legacy defstruct, using tagged vectors. Enable backward compatibility.
+ (cl-old-struct-compat-mode 1))
+ (if (eq type 'record)
+ ;; Defstruct using record objects.
+ (setq type nil))
(cl-assert (or type (not named)))
(if (boundp children-sym)
(add-to-list children-sym tag)