all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] scratch/record 3a49f62 4/4: Make cl-defstruct use records by default.
       [not found] ` <20170315214918.36D29208EF@vcs0.savannah.gnu.org>
@ 2017-03-15 23:40   ` Stefan Monnier
  0 siblings, 0 replies; only message in thread
From: Stefan Monnier @ 2017-03-15 23:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: Lars Brinkhoff

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-15 23:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20170315214916.23155.32300@vcs0.savannah.gnu.org>
     [not found] ` <20170315214918.36D29208EF@vcs0.savannah.gnu.org>
2017-03-15 23:40   ` [Emacs-diffs] scratch/record 3a49f62 4/4: Make cl-defstruct use records by default Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.