在HtDP 的练习 35.4.2 中,我实现了 GUI 并有一个名为“Remove”的按钮,它调用回调函数。这里是:
(define (cb-remove x)
((lambda (name result)
(cond
[(number? result) (remove-name name address-book)]
[else (draw-message msg "Not found")]))
(string->symbol (text-contents label-name))
(lookup (string->symbol (text-contents label-name)) address-book)))
当我运行它时,我收到以下消息:button-callback: result of type <Boolean> expected, your function produced #<set!-result>
. 问题是我必须打电话set!
才能更改通讯录。但是,set!
is的结果(void)
不能与布尔类型组合。我怎样才能避免这个问题?感谢您的任何见解。