unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Is there utility in making hash-table-{keys, values} built-in functions?
@ 2024-11-28 11:53 Shankar Rao
  2024-11-28 17:31 ` Mattias Engdegård
  2024-11-28 18:40 ` Gerd Möllmann
  0 siblings, 2 replies; 3+ messages in thread
From: Shankar Rao @ 2024-11-28 11:53 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 432 bytes --]

Hello all,

I noticed that the functions hash-table-keys and hash-table-values are just
wrappers around maphash. This means that there is no way to iterate over a
hash-table without using a lambda.

Would it be useful or worthwhile to implement these directly in C? I don't
know much about low-level Emacs development, but having these as built-ins
could make iteration of a hash-table a little faster and easier to debug.

Shankar

[-- Attachment #2: Type: text/html, Size: 545 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is there utility in making hash-table-{keys, values} built-in functions?
  2024-11-28 11:53 Is there utility in making hash-table-{keys, values} built-in functions? Shankar Rao
@ 2024-11-28 17:31 ` Mattias Engdegård
  2024-11-28 18:40 ` Gerd Möllmann
  1 sibling, 0 replies; 3+ messages in thread
From: Mattias Engdegård @ 2024-11-28 17:31 UTC (permalink / raw)
  To: Shankar Rao; +Cc: emacs-devel

28 nov. 2024 kl. 12.53 skrev Shankar Rao <shankar.rao@gmail.com>:

> I noticed that the functions hash-table-keys and hash-table-values are just wrappers around maphash. This means that there is no way to iterate over a hash-table without using a lambda.
> 
> Would it be useful or worthwhile to implement these directly in C? I don't know much about low-level Emacs development, but having these as built-ins could make iteration of a hash-table a little faster and easier to debug.

It's unlikely that it would be faster to make a list just for the purpose of a single iteration; the allocation costs alone would be too high. Other ways of iterating through hash-tables have been tried with mostly disappointing results, although there might be some value in avoiding use of the C stack in some cases.

If you tell us what you are trying to accomplish, it would be easier for us to help you.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is there utility in making hash-table-{keys, values} built-in functions?
  2024-11-28 11:53 Is there utility in making hash-table-{keys, values} built-in functions? Shankar Rao
  2024-11-28 17:31 ` Mattias Engdegård
@ 2024-11-28 18:40 ` Gerd Möllmann
  1 sibling, 0 replies; 3+ messages in thread
From: Gerd Möllmann @ 2024-11-28 18:40 UTC (permalink / raw)
  To: Shankar Rao; +Cc: emacs-devel

Shankar Rao <shankar.rao@gmail.com> writes:

> Hello all,
>
> I noticed that the functions hash-table-keys and hash-table-values are
> just wrappers around maphash. This means that there is no way to
> iterate over a hash-table without using a lambda.

If this is about syntax, cl-loop has support for hash tables. For
example

  for x being the hash-keys of something using (hash-value y)





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-28 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 11:53 Is there utility in making hash-table-{keys, values} built-in functions? Shankar Rao
2024-11-28 17:31 ` Mattias Engdegård
2024-11-28 18:40 ` Gerd Möllmann

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).