From: Thien-Thi Nguyen <ttn@gnu.org>
To: 28302@debbugs.gnu.org
Subject: bug#28302: 26.0.50; [PATCH] Make ucs-names a hash table
Date: Fri, 01 Sep 2017 12:43:16 +0200 [thread overview]
Message-ID: <87tw0m1yyj.fsf@zigzag> (raw)
In-Reply-To: <83mv6f0wfq.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 01 Sep 2017 09:23:05 +0300")
[-- Attachment #1: Type: text/plain, Size: 1722 bytes --]
() Eli Zaretskii <eliz@gnu.org>
() Fri, 01 Sep 2017 09:23:05 +0300
I suggest to update them to support a hash table as well as an
alist.
Tangent: Maybe we could extend ‘ucs-names’ (the function) to
take args and DTRT accordingly. Something like:
;; backward compatible
(ucs-names) => ALIST
;; lookup
(ucs-names 'forward-lookup CHAR-NAME) => CHAR-CODE
(ucs-names 'reverse-lookup CHAR-CODE) => CHAR-NAME
;; bonus: reflection
(ucs-names 'as-alist) => ALIST
(ucs-names 'as-hash-table) => HASH-TABLE
Admittedly, this is not very idiomatic Emacs Lisp. OTOH, i
would guess the vast majority of callers use it for lookup, so
centralizing that functionality would be a net win, despite the
style drift.
Really, given the rise of lexical binding and w/ niceties like
‘apply-partially’ already in the mix, i expect that sooner or
later, someone will put into place something like:
(defun callable-hash-table (source)
(let ((ht (ELABORATE source)))
;; rv
(lambda (&optional cmd)
(case cmd
(as-hash-table ht)
(as-alist ...)
(forward-lookup ...)
(reverse-lookup ...)
...))))
(fset ucs-names (callable-hash-table ucs-names))
IOW: Style drift be damned! Up the idioms! HOP things now!
(Insert more FP slogans here. :-D)
Or maybe this is already done? What am i missing? More coffee!
--
Thien-Thi Nguyen -----------------------------------------------
(defun responsep (query)
(pcase (context query)
(`(technical ,ml) (correctp ml))
...)) 748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
prev parent reply other threads:[~2017-09-01 10:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 5:04 bug#28302: 26.0.50; [PATCH] Make ucs-names a hash table Mark Oteiza
2017-08-31 10:05 ` Robert Pluim
2017-08-31 14:01 ` Eli Zaretskii
2017-08-31 14:00 ` Eli Zaretskii
2017-08-31 14:46 ` Mark Oteiza
2017-08-31 21:30 ` Mark Oteiza
2017-08-31 22:15 ` Drew Adams
2017-09-01 6:23 ` Eli Zaretskii
2017-09-01 10:43 ` Thien-Thi Nguyen [this message]
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=87tw0m1yyj.fsf@zigzag \
--to=ttn@gnu.org \
--cc=28302@debbugs.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.