hashtabl...function(3scm)

πŸ“¦ version 0-unstable-2024-02, in nixpkgs unstable

πŸ’… hashtabl...function(3scm) β€” like, the hashtable inspection girlies ✨

okay so before we even start: welcome to the Scheme Programmer's Manual, bestie πŸŽ€ this particular page is the hashtable inspection trio and honestly? they're the backstage-pass besties of the hashtable world. let's go 🌸


✨ NAME ✨

hashtable-equivalence-function, hashtable-hash-function, hashtable-mutable? β€” the hashtable inspection functions, aka the "wait, what's in this thing" girlies πŸ”


πŸ“š LIBRARY πŸ“š

(import (rnrs))                     ;R6RS
(import (rnrs hashtables))          ;R6RS

two ways in, both R6RS, pick your fighter πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

(hashtable-equivalence-function hashtable)
(hashtable-hash-function hashtable)
(hashtable-mutable? hashtable)

three procedures, one hashtable argument each. iconic, minimal, no notes 🫢


πŸ’« DESCRIPTION πŸ’«

hashtable-equivalence-function

this one hands you back the equivalence function that hashtable uses to compare keys πŸ‘‘ and here's the slay: if the hashtable was created by make-eq-hashtable(3scm) or make-eqv-hashtable(3scm), you get the procedure objects eq? and eqv? respectively. literally just hands you the actual function object. no cap πŸ’…

hashtable-hash-function

returns the hash function that hashtable is using. but plot twist 😭 β€” if the hashtable came from make-eq-hashtable(3scm) or make-eqv-hashtable(3scm), this one returns #f. yeah. #f. that's the whole vibe for those two.

hashtable-mutable?

the vibe check of the group 🌈 returns #t if hashtable is mutable, otherwise #f. that's it. that's the procedure.


🎁 RETURN VALUES 🎁

all three return a single value β€” an object as described above. one value, no bundling, we're not doing that here πŸŽ€


🌸 APPLICATION USAGE 🌸

ngl these procedures are rarely used outside of procedures that print hashtables. that's their whole social circle 🫢 like yes they're serving but they're serving a niche.


🧚 RATIONALE 🧚

okay so why does hashtable-hash-function be giving #f for the eq/eqv girlies? πŸ‘€ because the hash functions for hashtables created by make-eq-hashtable(3scm) or make-eqv-hashtable(3scm) are private to the implementation. and the reason is actually so valid: implementations may use garbage collectors that move objects, and that movement can change the hash value of the affected objects 😭 so yeah, keeping it private is the move. periodt.


πŸ”₯ COMPATIBILITY πŸ”₯

these procedures are unique to R6RS πŸ’œ compatible procedures can sorta be found in SRFI-69, SRFI-125 and SRFI-126. "sorta" is doing a lot of heavy lifting there but we respect it 🫑


πŸ’€ ERRORS πŸ’€

this procedure can raise exceptions with the following condition types:

  • &assertion (R6RS) β€” bestie, the wrong number of arguments was passed, or an argument was outside its domain 😭 in particular, hashtable should be a hashtable. like. that's the bare minimum. please pass a hashtable πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

  • make-hashtable(3scm) β€” go read that one next, fr fr

⭐ STANDARDS ⭐

R6RS πŸŽ€


🌈 HISTORY 🌈

these procedures first appeared in R6RS's hashtable library, which was based on SRFI-69 β€” and SRFI-69 also has the first two procedures πŸ’– so like, they've been around. legacy icons.


πŸ‘‘ AUTHORS πŸ‘‘

this page is part of the scheme-manpages project ✨ it includes materials from the RnRS documents. more information can be found at https://github.com/schemedoc/manpages/ πŸ¦‹


and that's the whole page bestie, tysm for reading πŸ’…βœ¨ mwah 🫢

this lil cutie dropped 2023-01-22 and it lives in the Scheme Programmer's Manual (that's the source/version vibes) β€” see u in the next manpage, love u, bye πŸŽ€πŸ’–

πŸ“¦ where this page comes from