emacs-devel
[Top][All Lists]
Advanced

[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


From: Stefan Monnier
Subject: Re: [Emacs-diffs] scratch/record 3a49f62 4/4: Make cl-defstruct use records by default.
Date: Wed, 15 Mar 2017 19:40:45 -0400
User-agent: 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
builtin types).

> -    (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 ...).


        Stefan



reply via email to

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