[racket users] Contracts and make-keyword-procedure question

12 views
Skip to first unread message

Kevin Forchione

unread,
Aug 23, 2019, 7:07:12 PM8/23/19
to Racket-Users List
Suppose I have the following:

(define/contract foo (-> ??? any/c symbol? symbol? any/c any)
(make-keyword-procedure (lambda (kw kv a b . args) do-something …)))

What sort of contract would I give to the kw parameter so that it basically accepts a list of unspecified keywords? What I’m doing is passing that information along to keyword-apply and the function derived from other argument data. I’d like to be able to skip the contract on the keywords at the moment, and simply enforce the other arguments.

What I get is an error message that would say that foo expects no keywords, but was supplied them, as might be the case, even with any/c specified.

Any suggestions are appreciated.

Kevin

Ben Greenman

unread,
Aug 24, 2019, 10:39:09 AM8/24/19
to Kevin Forchione, Racket-Users List
The -> combinator doesn't support unspecified keywords. ->* won't work either.

Instead, you can try writing a new contract combinator (keyword-procedure/c ?)

Or, don't use define/contract and put the domain checks in the function body.
Reply all
Reply to author
Forward
0 new messages