From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tomas Hlavaty Newsgroups: gmane.emacs.devel Subject: Re: Is there utility in making hash-table-{keys, values} built-in functions? Date: Fri, 29 Nov 2024 23:05:37 +0100 Message-ID: <874j3plmq6.fsf@neko.mail-host-address-is-not-set> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7304"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org, Mattias =?utf-8?Q?Engdeg=C3=A5rd?= To: Shankar Rao Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 29 23:06:50 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tH98U-0001pc-OK for ged-emacs-devel@m.gmane-mx.org; Fri, 29 Nov 2024 23:06:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tH97a-00037B-Pw; Fri, 29 Nov 2024 17:05:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH97Z-00036w-4i for emacs-devel@gnu.org; Fri, 29 Nov 2024 17:05:53 -0500 Original-Received: from logand.com ([37.48.87.44]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tH97X-0005zT-Iz for emacs-devel@gnu.org; Fri, 29 Nov 2024 17:05:52 -0500 Original-Received: by logand.com (Postfix, from userid 1001) id AE7601A036A; Fri, 29 Nov 2024 23:05:39 +0100 (CET) X-Mailer: emacs 29.4 (via feedmail 11-beta-1 I) In-Reply-To: Received-SPF: pass client-ip=37.48.87.44; envelope-from=tom@logand.com; helo=logand.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:325859 Archived-At: On Fri 29 Nov 2024 at 15:25, Shankar Rao wrote: > while the latter require a lambda, which are generally slower and > harder to debug. If that is the case then it would be better to improve the debuger. >> This means that there is no way to iterate over a hash-table without >> using a lambda. Iterating over a hash-table using a callback is not such a problem. More interesting is that it is not possible to suspend and resume the iteration. And even more interesting is that it is generally undefined to change the hash-table inside map-hash callback. hash-tables are complex objects compared to lists or arrays and map-hash hides a lot of complexity trying to provide reasonable interface. Even worse is the lisp interface to list directory, e.g. directory-files, directory-files-and-attributes, directory-files-recursively. Here one gets the whole thing as a list all at once. And the filter is quite limited and not programable. So if I want something uncommon or faster, an external program is likely a better choice. Compare that to C/POSIX interface which provides a way to iterate over the directory. Or maybe instead of worrying about closing files, a map-hash like interface, e.g. map-directory, would be better?