Re: [racket] question about implementation of hash-ref!

2014-11-07 Thread Jack Firth
Making it the default behavior would require it to be a macro instead of an ordinary function, so you’d lose the ability to pass it around as a function. Given that implementing a short circuit macro on top of hash-ref! is as simple as (define-syntax-rule (hash-ref!! table key expr) (hash-ref! tabl

Re: [racket] question about implementation of hash-ref!

2014-11-07 Thread Jay McCarthy
The simplest, boring, answer is that short-circuiting requires that hash-ref! be a macro, which makes it difficult to use in first-class ways, like storing it inside of a list. There are many other functions like this and the pattern of accepting a value OR a thunk is pretty common, for this reason