From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: [PATCH] Add new function to test whether a key is present in a hash table. Date: Mon, 19 Feb 2018 09:26:37 -0800 (PST) Message-ID: <6af0cc2c-b5ba-4736-8772-1c10f0e95dec@default> References: <20180215203406.64372-1-phst@google.com>> <2ce9b5db-b17d-415c-8dc6-6046a31269be@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1519061158 6408 195.159.176.226 (19 Feb 2018 17:25:58 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 19 Feb 2018 17:25:58 +0000 (UTC) Cc: Philipp Stephani , Philipp Stephani , emacs-devel@gnu.org To: John Wiegley Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 19 18:25:53 2018 Return-path: Envelope-to: ged-emacs-devel@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 1enpC9-0000Ut-8f for ged-emacs-devel@m.gmane.org; Mon, 19 Feb 2018 18:25:41 +0100 Original-Received: from localhost ([::1]:51546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enpE9-0007y7-PM for ged-emacs-devel@m.gmane.org; Mon, 19 Feb 2018 12:27:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58373) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1enpDG-0007uj-Uy for emacs-devel@gnu.org; Mon, 19 Feb 2018 12:26:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1enpDE-00071q-8P for emacs-devel@gnu.org; Mon, 19 Feb 2018 12:26:50 -0500 Original-Received: from aserp2130.oracle.com ([141.146.126.79]:36074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1enpDE-000710-0G; Mon, 19 Feb 2018 12:26:48 -0500 Original-Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1JHOLcb026446; Mon, 19 Feb 2018 17:26:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=H7WgZdZ9mLtee30QkNHxmYx/MKk3sBwUJruXK0NzuFg=; b=Dto5oowaUZHaytpmZTTIkLU8pN4IaiKG1Ji6UAijQ2fUagen611W3YDZv0hE8zI39hYt 5qd4WhaWY1eLSFtO0DRstT/ev++TWf1Gnc8rZmUhVzgo/DI88yBUC8SssiTN9MuaRsD/ U9n6QmJ+tal3OCRCqVwQZ4MMsHyoliKTWYdz1U3NsvDjkUDJ7nfs6DYTY0HzZr4Bpval OjDuJazm4ivxPt8jXaJ2k6QTwpPRjxo/wd76Aw3oDtVnWVAmzkREZKX25gI3bMpuX9In 0joefBvD2T+86xSMjpHjT+rZvuBDs9H0dRpWIXzPrie9Mk8ScMJ7ThdInKMjN0g6crKv aQ== Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2g818k8f6a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Feb 2018 17:26:38 +0000 Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1JHQb7J022959 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 19 Feb 2018 17:26:37 GMT Original-Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1JHQboG008146; Mon, 19 Feb 2018 17:26:37 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4654.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8808 signatures=668674 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802190214 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.79 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:222905 Archived-At: > DA> 2. The function name should have `key' in it, I think. Suggestion: > DA> `hash-table-contains-key-p' or even just `hash-table-key-p'. >=20 > It seems a bit strange that the name isn't something like "hashash", > since knowing "puthash" and "gethash" would never help you guess > hash-table-contains-key-p. Right. And knowing `hash-table-contains-key-p' wouldn't help you guess `puthash' or `get-hash'. But that's the fault of `puthash' and `gethash'. ;-) It's `puthash' and `gethash' that are not so conventional for Emacs. They are borrowed from Common Lisp. Likewise, `maphash', `remhash', and `clrhash'. Those names predate Common Lisp even. `puthash', `gethash', `remhash', etc. could be made aliases of, say, `hash-table-put', `hash-table-get', `hash-table-remove', etc. (I'm not saying they should.) `puthash' seems to be the only Emacs `put*' function whose name doesn't start with `put-' (apart from `put' itself). Same thing for `gethash' (except that there are also `getenv' and `getf'). The Emacs convention is to use prefix `put-' or `get-'. Another (more common?) convention in Emacs is to put the object type first: `string-match', `bool-vector-union', `mode-line-next-buffer', `menu-bar-open', `marker-buffer', `buffer-size', `window-child', `frame-edges', etc., especially for functions that extract parts of an object. Yet another convention is to put the verb first, especially for "utility" verbs: `map-*', `make-*', `put-*', `get-*', `copy-*', `delete-*', etc. Finally, a library prefix is often used: `ad-get-*', `ange-ftp-get-*', `bookmark-get-*', `comint-get-*', `dired-get-*', `ediff-get-*', `gnus-get-*' ... These are the functions I see with "hash" in their names: 0. Those that (I guess) have nothing to do with hash tables: ange-ftp-guess-hash-mark-size ange-ftp-process-handle-hash buffer-hash gnutls-hash-digest hashcash-insert-payment hashcash-insert-payment-async hashcash-verify-payment rfc2104-hash sxhash sxhash-eq sxhash-eql sxhash-equal I mention these to point out that names like `puthash' don't really, on their own, make clear that they have to do with a hash table. 1. Those that are about hash-table hashing but (I guess) don't have a hash table as the main object: gnus-create-hash-size gnutls-hash-mac secure-hash secure-hash-algorithms 2. Those (non-CL) that have a hash table as the main object: ange-ftp-hash-entry-exists-p ange-ftp-hash-table-keys clrhash copy-hash-table define-hash-table-test define-translation-hash-table gethash gnus-make-hashtable hash-table-count hash-table-p hash-table-rehash-size hash-table-rehash-threshold hash-table-size hash-table-test hash-table-weakness make-hash-table maphash puthash remhash ucs-normalize-make-hash-table-from-alist 3. Common-Lisp emulation functions for hash tables: cl-clrhash cl-gethash cl-hash-table-count cl-hash-table-p cl-make-hash-table cl-maphash cl-not-hash-table=20 cl-puthash cl-remhash Note that except for those names inherited from older Lisps, Common Lisp spells out `hash-table' in the function names. The most common convention, so far, for Emacs hash-table functions is to start the function name with `hash-table'. That accords with the convention of putting the object name first.