;; for bootstrapping reasons.
(defvar cl--struct-default-parent nil)
+(defvar cl--struct-inline t
+ "If non-nil, `cl-defstruct' will define inlinable functions.")
+
;;;###autoload
(defmacro cl-defstruct (struct &rest descs)
"Define a struct type.
NAME may instead take the form (NAME OPTIONS...), where each
OPTION is either a single keyword or (KEYWORD VALUE) where
KEYWORD can be one of :conc-name, :constructor, :copier, :predicate,
-:type, :named, :initial-offset, :print-function, or :include.
+:type, :named, :initial-offset, :print-function, :noinline, or :include.
Each SLOT may instead take the form (SNAME SDEFAULT SOPTIONS...), where
SDEFAULT is the default value of that slot and SOPTIONS are keyword-value
(include-name nil)
(type nil) ;nil here means not specified explicitly.
(named nil)
+ (cldefsym (if cl--struct-inline 'cl-defsubst 'cl-defun))
+ (defsym (if cl--struct-inline 'cl-defsubst 'defun))
(forms nil)
(docstring (if (stringp (car descs)) (pop descs)))
pred-form pred-check)
(error "Invalid :type specifier: %s" type)))
((eq opt :named)
(setq named t))
+ ((eq opt :noinline)
+ (setq defsym 'defun) (setq cldefsym 'cl-defun))
((eq opt :initial-offset)
(setq descs (nconc (make-list (car args) '(cl-skip-slot))
descs)))
(cons 'and (cl-cdddr pred-form))
`(,predicate cl-x))))
(when pred-form
- (push `(cl-defsubst ,predicate (cl-x)
+ (push `(,defsym ,predicate (cl-x)
(declare (side-effect-free error-free))
,(if (eq (car pred-form) 'and)
(append pred-form '(t))
(push (pop desc) defaults)
;; The arg "cl-x" is referenced by name in eg pred-form
;; and pred-check, so changing it is not straightforward.
- (push `(cl-defsubst ,accessor (cl-x)
+ (push `(,defsym ,accessor (cl-x)
,(format "Access slot \"%s\" of `%s' struct CL-X."
slot struct)
(declare (side-effect-free t))
(let* ((anames (cl--arglist-args args))
(make (cl-mapcar (function (lambda (s d) (if (memq s anames) s d)))
slots defaults)))
- (push `(cl-defsubst ,cname
+ (push `(,cldefsym ,cname
(&cl-defs (nil ,@descs) ,@args)
,(if (stringp doc) doc
(format "Constructor for objects of type `%s'." name))