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: Thu, 15 Feb 2018 17:03:37 -0800 (PST) Message-ID: References: <20180215203406.64372-1-phst@google.com> 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 1518742926 4349 195.159.176.226 (16 Feb 2018 01:02:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 16 Feb 2018 01:02:06 +0000 (UTC) To: Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 16 02:02:02 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 1emUPO-00005j-D1 for ged-emacs-devel@m.gmane.org; Fri, 16 Feb 2018 02:01:50 +0100 Original-Received: from localhost ([::1]:50538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emURQ-0007j2-60 for ged-emacs-devel@m.gmane.org; Thu, 15 Feb 2018 20:03:56 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emURH-0007iW-88 for emacs-devel@gnu.org; Thu, 15 Feb 2018 20:03:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emURE-0003Ol-3r for emacs-devel@gnu.org; Thu, 15 Feb 2018 20:03:47 -0500 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:58580) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1emURD-0003NL-Sd for emacs-devel@gnu.org; Thu, 15 Feb 2018 20:03:44 -0500 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1G13gPJ034094; Fri, 16 Feb 2018 01:03:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=UW4DATHn3GmBC3y6sq8Wfpn+sidPgbMQ6IB17wRSigw=; b=fA9FjxSAX/vpQcAJ8Lc/GXtEGIkh+GVcDFbOprQEBH4SEDnwHsqpxSXD6zqDJynv7KYJ ZgsVWmH3sk1zr4dhDRZKJ9Hn6r4XhmG2n2InVb1P6L/FzwuUmNEKWX+JCWRRbPDVDFZy P/GqneU8DIzziv0trThyAR5HgVumhHZfCQ+NH0yBc231xSB6OK+41Z2k6kY3jKnubX5W g19eHAizjsqqudMBx8+KgNNVUnWNDusdozuixAfAxlRrGWTOfE5J4Zd43yCEFHrqy8wY ZD77sJAzrVh58BKBfvfs7JohK7NzXcUSZ3YlIZNoGtYhutKoYO6Z6JQ2pzkOyH0QIjsc 8A== Original-Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2g5mvt83wt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Feb 2018 01:03:42 +0000 Original-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1G13fkV006615 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 16 Feb 2018 01:03:41 GMT Original-Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1G13cXJ020915; Fri, 16 Feb 2018 01:03:40 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=8806 signatures=668672 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=609 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802160010 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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:222792 Archived-At: > > Such a function is useful because in Emacs Lisp, 'gethash' > > cannot return whether the key is present as in Common Lisp, > > and using 'gethash' alone to test for presence is nontrivial. >=20 > We could also implement it in Elisp: > (defun hash-table-contains-p (key table) > (let ((x '(:hash-table-contains-p))) > (not (eq x (gethash key table x))))) Yes, as I said: Everyone was coding their own (in Lisp). using a unique cons, uninterned symbol, or some other unique object. Philipp used an uninterned symbol: (let ((uniq-symb '#:void)) (not (eq uniq-symb (gethash key table uniq-symb)))) I (like you) used a unique cons: (let ((uniq-cons (cons 1 1))) (not (eq uniq-cons (gethash key table uniq-cons)))) But isn't it better to define this in C? https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D28753