[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] scratch/record 3a49f62 4/4: Make cl-defstruct use reco
Re: [Emacs-diffs] scratch/record 3a49f62 4/4: Make cl-defstruct use records by default.
Wed, 15 Mar 2017 19:40:45 -0400
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)
> (defun cl--generic-struct-tag (name &rest _)
> - ;; It's tempting to use (and (vectorp ,name) (aref ,name 0))
> - ;; but that would suffer from some problems:
> - ;; - the vector may have size 0.
> - ;; - when called on an actual vector (rather than an object), we'd
> - ;; end up returning an arbitrary value, possibly colliding with
> - ;; other tagcode's values.
> - ;; - it can also result in returning all kinds of irrelevant
> - ;; values which would end up filling up the method-cache with
> - ;; lots of irrelevant/redundant entries.
> - ;; FIXME: We could speed this up by introducing a dedicated
> - ;; vector type at the C level, so we could do something like
> - ;; (and (vector-objectp ,name) (aref ,name 0))
> - `(and (vectorp ,name)
> - (> (length ,name) 0)
> - (let ((tag (aref ,name 0)))
> - (and (symbolp tag)
> - (eq (symbol-function tag) :quick-object-witness-check)
> - tag))))
> + `(and (recordp ,name) (aref ,name 0)))
Actually, you can use `type-of`, here (IOW it can use the same code as
the one used for builtin types, which will make dispatch more efficient
for generic functions which have methods both for structs and for
> - (if (eq type 'record)
> - (setq named t))
We don't need to support (:type record). `record` should simply be used
by default in the absence of any (:type ...).
|[Prev in Thread]
||[Next in Thread]|
- Re: [Emacs-diffs] scratch/record 3a49f62 4/4: Make cl-defstruct use records by default.,
Stefan Monnier <=