From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.bugs Subject: bug#28302: 26.0.50; [PATCH] Make ucs-names a hash table Date: Fri, 01 Sep 2017 12:43:16 +0200 Message-ID: <87tw0m1yyj.fsf@zigzag> References: <87r2vsqqeo.fsf@holos> <83tw0n25xo.fsf@gnu.org> <87tw0n4wxz.fsf@holos> <20170831213049.GA5321@holos.localdomain> <83mv6f0wfq.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1504262367 4338 195.159.176.226 (1 Sep 2017 10:39:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 1 Sep 2017 10:39:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: 28302@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 01 12:39:23 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnjLz-0000HI-Gr for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Sep 2017 12:39:11 +0200 Original-Received: from localhost ([::1]:34419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnjM4-0006rE-U7 for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Sep 2017 06:39:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnjLv-0006q6-Ln for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2017 06:39:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnjLq-0007uM-Nr for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2017 06:39:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58769) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dnjLq-0007uF-Jr for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2017 06:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dnjLq-0007Au-DY for bug-gnu-emacs@gnu.org; Fri, 01 Sep 2017 06:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thien-Thi Nguyen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Sep 2017 10:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28302 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 28302-submit@debbugs.gnu.org id=B28302.150426233527564 (code B ref 28302); Fri, 01 Sep 2017 10:39:02 +0000 Original-Received: (at 28302) by debbugs.gnu.org; 1 Sep 2017 10:38:55 +0000 Original-Received: from localhost ([127.0.0.1]:39217 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnjLh-0007AV-GR for submit@debbugs.gnu.org; Fri, 01 Sep 2017 06:38:54 -0400 Original-Received: from mail.agora-net.com ([67.59.132.6]:59790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnjLg-0007AO-4y for 28302@debbugs.gnu.org; Fri, 01 Sep 2017 06:38:52 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.82) (envelope-from ) id 1dnjLf-0008Hd-L7 for 28302@debbugs.gnu.org; Fri, 01 Sep 2017 06:38:51 -0400 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1dnjQ9-0001OV-6P for 28302@debbugs.gnu.org; Fri, 01 Sep 2017 12:43:29 +0200 In-Reply-To: <83mv6f0wfq.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 01 Sep 2017 09:23:05 +0300") X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ttn@gnuvola.org X-SA-Exim-Scanned: No (on mail.agora-net.com); SAEximRunCond expanded to false X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:136439 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Eli Zaretskii () 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 =E2=80=98ucs-names=E2=80=99 (the function) to take args and DTRT accordingly. Something like: ;; backward compatible (ucs-names) =3D> ALIST ;; lookup (ucs-names 'forward-lookup CHAR-NAME) =3D> CHAR-CODE (ucs-names 'reverse-lookup CHAR-CODE) =3D> CHAR-NAME ;; bonus: reflection (ucs-names 'as-alist) =3D> ALIST (ucs-names 'as-hash-table) =3D> 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 =E2=80=98apply-partially=E2=80=99 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! =2D-=20 Thien-Thi Nguyen ----------------------------------------------- (defun responsep (query) (pcase (context query) (`(technical ,ml) (correctp ml)) ...)) 748E A0E8 1CB8 A748 9BFA =2D-------------------------------------- 6CE4 6703 2224 4C80 7502 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlmpOcoACgkQZwMiJEyAdQK70wCgyIzbtm18oSRiUtkKVPh9T6Ro HC4AoOC7DoASCjzllW9KB3hB3d5v6621 =Hzib -----END PGP SIGNATURE----- --=-=-=--