[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get plist properties list?
From: |
Stefan Monnier |
Subject: |
Re: How to get plist properties list? |
Date: |
Tue, 12 Jan 2021 16:23:58 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (defun mutt-identity-signature (identity)
> (let* ((sql (format "SELECT * FROM identities WHERE identities_id = %s"
> identity))
> (list (first (rcd-sql-list sql *cf*)))
> (identity-id (elt list 0))
> (identity-name (elt list 1))
> (identity-first-name (elt list 2))
> (identity-last-name (elt list 3))
That's a completely different situation: the above code does not operate
on a list of elements of arbitrary length, but on what is fundamentally
a tuple of fixed length which just happens to be represented as a Lisp
linked list.
> (defun mapping/map-locations-point-kml-placemark (p)
> (mapping/kml-placemark (elt p 3) (elt p 4) (list (elt p 0) (elt p 1) (elt p
> 2))))
Notice that the "n" passed to `elt` is a constant, whereas in the
original code where I pointed out the problem:
(dotimes (i length (reverse properties))
(if (divisible-by-2-or-0-p i)
(push (elt plist i) properties)))))
the argument to `elt` (here `i`) is not a constant.
That changes the nature of the problem completely.
(elt FOO 100)
may be arguably slow, but it's still constant time, so it won't get
slower when applied to a larger data-structure. In contrast
(elt FOO i)
will probably be fairly fast on small data structures, where `i` is
small, but it will get slower and slower as `i` grows with the size of
the data structure.
Stefan
- RE: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, (continued)
- RE: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Drew Adams, 2021/01/08
- How to get plist properties list?, Jean Louis, 2021/01/07
- Re: How to get plist properties list?, Stefan Monnier, 2021/01/08
- Re: How to get plist properties list?, Jean Louis, 2021/01/08
- Re: How to get plist properties list?, Stefan Monnier, 2021/01/08
- Re: How to get plist properties list?, Jean Louis, 2021/01/09
- Re: How to get plist properties list?, tomas, 2021/01/09
- Re: How to get plist properties list?, Jean Louis, 2021/01/10
- Re: How to get plist properties list?, Stefan Monnier, 2021/01/09
- Re: How to get plist properties list?, Jean Louis, 2021/01/12
- Re: How to get plist properties list?,
Stefan Monnier <=
- Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Jean Louis, 2021/01/07
Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'?, Stefan Monnier, 2021/01/07