[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)))
- new `obarray` type, Stefan Monnier, 2017/03/12
- Re: new `obarray` type, Eli Zaretskii, 2017/03/13
- Re: new `obarray` type, Alan Mackenzie, 2017/03/13
- Re: new `obarray` type, Herring, Davis, 2017/03/13
- Re: new `obarray` type, Stefan Monnier, 2017/03/14
- Re: new `obarray` type, Alan Mackenzie, 2017/03/14
- Re: new `obarray` type, Stefan Monnier, 2017/03/15
- Re: new `obarray` type, Lars Brinkhoff, 2017/03/15
- (:named nil) in cl-defstruct (was: new `obarray` type),
Stefan Monnier <=
- Re: (:named nil) in cl-defstruct (was: new `obarray` type), Noam Postavsky, 2017/03/15
- Re: (:named nil) in cl-defstruct, Stefan Monnier, 2017/03/15