From: Ted Zlatanov <tzz@lifelogs.com>
To: emacs-devel@gnu.org
Subject: Re: possible json.el optimization: json-alist-p and json-plist-p recursion
Date: Fri, 14 Oct 2011 10:09:40 -0400 [thread overview]
Message-ID: <87lisnr7ff.fsf@lifelogs.com> (raw)
In-Reply-To: 87lisoswn9.fsf@lifelogs.com
On Thu, 13 Oct 2011 12:07:22 -0400 Ted Zlatanov <tzz@lifelogs.com> wrote:
TZ> Good points, I had the `car-safe' and `cdr-safe' calls left over from
TZ> earlier code, and I was copying into p unnecessarily. This is better, I
TZ> think:
#+begin_src lisp
(defun gnus-sync-json-alist-p (list)
"Non-null if and only if LIST is an alist."
(while (consp list)
(setq list (if (consp (car list))
(cdr list)
'not-alist)))
(null list))
(defun gnus-sync-json-plist-p (list)
"Non-null if and only if LIST is a plist."
(while (consp list)
(setq list (if (and (keywordp (car list))
(consp (cdr list)))
(cddr list)
'not-plist)))
(null list))
#+end_src
Emacs Lisp doesn't have `alist-p' or `plist-p' which these functions
could provide. So instead of fixing just json.el, can I move these
functions to the core and rewrite json.el accordingly? I think that
would be useful.
But here's why I didn't just do it: these functions are exclusive,
meaning they don't accept a general list that has cons cells. So this
example list is OK with `assq' but would fail the proposed `alist-p':
(assq 1 '((1 . 2) 3))
WDYT? Should I change the name to `[ap]list-pure-p' or something like
that? Or is this too limited to be generally useful?
Thanks
Ted
next prev parent reply other threads:[~2011-10-14 14:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 13:51 possible json.el optimization: json-alist-p and json-plist-p recursion Ted Zlatanov
2011-10-13 14:31 ` Stefan Monnier
2011-10-13 16:07 ` Ted Zlatanov
2011-10-14 14:09 ` Ted Zlatanov [this message]
2011-10-14 14:58 ` Stefan Monnier
2011-10-14 16:33 ` Ted Zlatanov
2011-10-14 17:02 ` Edward O'Connor
2011-10-17 17:41 ` Ted Zlatanov
2011-10-13 16:02 ` Edward O'Connor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lisnr7ff.fsf@lifelogs.com \
--to=tzz@lifelogs.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.