GNU bug report logs -
#28302
26.0.50; [PATCH] Make ucs-names a hash table
Previous Next
Reported by: Mark Oteiza <mvoteiza <at> udel.edu>
Date: Thu, 31 Aug 2017 05:05:01 UTC
Severity: wishlist
Tags: patch
Found in version 26.0.50
Done: Mark Oteiza <mvoteiza <at> udel.edu>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
() Eli Zaretskii <eliz <at> 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
[signature.asc (application/pgp-signature, inline)]
This bug report was last modified 7 years and 322 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.