emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(:named nil) in cl-defstruct (was: new `obarray` type)


From: Stefan Monnier
Subject: (:named nil) in cl-defstruct (was: new `obarray` type)
Date: Wed, 15 Mar 2017 15:24:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>> I can recover some of the speed by adding (:type vector) (:named nil)
>> to the defstruct definition.
> Does that work for you?  It seems to me that (:named nil) does the
> opposite of what you would think.

Oh, right, indeed.  :named works by "present/absent", so you can use

    (:type vector)
    :named

for "named" and just

    (:type vector)

for "unnamed".

Common-Lisp doesn't allow (:named ...), but cl-macs.el treats it
as :named hence the confusion.  I think we should change this to either
disallow (:named ...) or to treat (:named nil) as a way to say "*not*
named".  The patch below does latter.  Any objection?


        Stefan


diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index ee32c3444f..6e95154daa 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2675,7 +2675,7 @@ cl-defstruct
              ((eq opt :type)
               (setq type (car args)))
              ((eq opt :named)
-              (setq named t))
+              (setq named (if args (car args) t)))
              ((eq opt :initial-offset)
               (setq descs (nconc (make-list (car args) '(cl-skip-slot))
                                  descs)))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]