[racket] lambda as default value to dict-ref

From: J G Cho (gcho at fundingmatters.com)
Date: Fri Feb 15 21:54:58 EST 2013

So, I have a dict A that looks like (list ("string as key" . (lambda
(arg) ...) ...)

I do ((dict-ref A key (lambda (_) "wrong key")) some-params).

When keys are valid the above work as expected. When the key does not
find any, I was expecting

((lambda (_) "wrong key") some-params) but it fails with this msg:

 arity mismatch;
 the expected number of arguments does not match the given number
  expected: 1
  given: 0

Upon further inspection,

(dict-ref A key (lambda (_) "wrong key"))  does not seem to return the
lambda but seems to invoke it. Why so? What am I failing to understand



Posted on the users mailing list.