[plt-dev] Suggestion: `with-hash'
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.
Ryan