I think you want hash-clear! because I think you're using a mutable hashtable.
hash-clear! is for mutable hashtables (built with make-hash, added to with hash-add!) and returns void after it updates its argument hash-clear is for immutable hashes (build with hash or for/hash, added to with hash-add) and returns a new hashtable -- for example: > (define h (hash 'a 1)) > (define i (hash-clear h)) > (hash-count h) 1 > (hash-count i) 0 The notes on chaperones & impersonators are only about efficiency. They shouldn't affect your choice. On Sun, Apr 24, 2016 at 5:11 AM, Damien Mattei <[email protected]> wrote: > hi, > > what is the best way to clear a hash table, hash-clear or hash-clear! ? if > the hash-table is defined in a code at top-level and used in functions as a > global variable, the issue i have is that when at REPL i use a first time > my function (that use hash-table) it's ok but when i reuse the function it > returns a wrong result as the hash-table is not redefined and cleared and > has data in it that make interfere with reuse of hash-table, so i need to > clear it ... > i tried to read the story about chaperone and impersonator in the doc but > my english and the specificities of drracket scheme make that i do not > understand which of hash-clear or hash-clear! is more appropriate in this > case. > > regards, > > damien > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

