On Fri, Jun 27, 2014 at 4:08 PM, Manfred Lotz <manfred.l...@arcor.de> wrote: > On Fri, 27 Jun 2014 15:59:47 -0400 > "Alexander D. Knauth" > <alexan...@knauth.org> wrote: > >> Are you sure you meant "hash-ref!" and not just "hash-ref”? >> > > Well I thought hash-ref! is the way to go because I just wanted #f in > case of not found. > >> Because even with (hash-ref! my-hash size (lambda () #f)), it would >> expect the #f to be of type (Listof String), which it isn’t. >> > > Oops, that makes the difference. Using hash-ref works fine now. > It seems that in untyped racket hash-ref! is fine but it is not suited > for typed racket.
When you use `hash-ref!`, you're actually changing the hash table, not just returning #f in the case that the key isn't found. Typed Racket doesn't let you change the hash table to have the wrong kind of data in it. So using `hash-ref!` is wrong both with typed or untyped Racket -- the type checker is just catching the bug. Sam ____________________ Racket Users list: http://lists.racket-lang.org/users