[plt-dev] Suggestion: `with-hash'

From: Ryan Culpepper (ryanc at ccs.neu.edu)
Date: Fri Mar 27 00:33:08 EDT 2009

Eli Barzilay wrote:
> Here's a suggestion for a small addition to `scheme/base', with the
> obvious meaning:
>   (with-hash <hash> <key> <expr>)
>     Lookup <key> in <hash> and return the found value.  If there is
>     no value evaluate <expr>, store it in <hash> for the <key>, and
>     return it.
>  [...]
> Any objections?

I don't like the name. I think you should make it a procedure (use the 
normal hash value/thunk convention) and name it 'hash-ref/default!' or 
something similarly descriptive.

Also, how about making it generic instead and adding it to scheme/dict? 
I'd rather procedures for common usage patterns of dictionaries were put 
in scheme/dict than added to the base language.


Posted on the dev mailing list.