diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-27 22:41:31 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2015-01-27 22:41:31 -0500 |
commit | 2668ac1aaecfe62c80a4fbdfc27a38e384594d26 (patch) | |
tree | f467b3db81d3510c67c01052ca620e6ade7a357d /lisp/emacs-lisp/cl-preloaded.el | |
parent | 7f4f16b3ae6fdb59d83cfc01017668f2a564309f (diff) | |
download | emacs-2668ac1aaecfe62c80a4fbdfc27a38e384594d26.tar.gz |
Tighten up the tagcode used for eieio and cl-struct objects
* lisp/emacs-lisp/eieio-core.el (eieio-defclass-internal): Set the function
slot of the tag symbol to :quick-object-witness-check.
(eieio-object-p): Use :quick-object-witness-check.
(eieio--generic-tagcode): Use cl--generic-struct-tag.
* lisp/emacs-lisp/cl-preloaded.el: New file.
* lisp/emacs-lisp/cl-macs.el (cl--bind-inits): Remove, unused.
(cl--transform-lambda, cl-destructuring-bind): Remove cl--bind-inits.
(cl--make-usage-args): Strip away &aux args.
(cl-case, cl-typecase, cl--parse-loop-clause): Use macroexp-let2.
(cl-the, cl-check-type): Use macroexp-let2 and cl-typep.
(cl-defstruct): Use `declare' and cl-struct-define.
* lisp/emacs-lisp/cl-generic.el (cl--generic-struct-tag): New function.
(cl--generic-struct-tagcode): Use it to tighten the tagcode.
* lisp/loadup.el: Load cl-preloaded.
* src/lisp.mk (lisp): Add cl-preloaded.
Diffstat (limited to 'lisp/emacs-lisp/cl-preloaded.el')
-rw-r--r-- | lisp/emacs-lisp/cl-preloaded.el | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el new file mode 100644 index 00000000000..c9867b412a1 --- /dev/null +++ b/lisp/emacs-lisp/cl-preloaded.el @@ -0,0 +1,48 @@ +;;; cl-preloaded.el --- Preloaded part of the CL library -*- lexical-binding: t; -*- + +;; Copyright (C) 2015 Free Software Foundation, Inc + +;; Author: Stefan Monnier <monnier@iro.umontreal.ca> + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;; The expectation is that structs defined with cl-defstruct do not +;; need cl-lib at run-time, but we'd like to hide the details of the +;; cl-struct metadata behind the cl-struct-define function, so we put +;; it in this pre-loaded file. + +;;; Code: + +(defun cl-struct-define (name docstring parent type named slots children-sym + tag print-auto) + (if (boundp children-sym) + (add-to-list children-sym tag) + (set children-sym (list tag))) + ;; If the cl-generic support, we need to be able to check + ;; if a vector is a cl-struct object, without knowing its particular type. + ;; So we use the (otherwise) unused function slots of the tag symbol + ;; to put a special witness value, to make the check easy and reliable. + (unless named (fset tag :quick-object-witness-check)) + (put name 'cl-struct-slots slots) + (put name 'cl-struct-type (list type named)) + (if parent (put name 'cl-struct-include parent)) + (if print-auto (put name 'cl-struct-print print-auto)) + (if docstring (put name 'structure-documentation docstring))) + +(provide 'cl-preloaded) +;;; cl-preloaded.el ends here |