I have written a complimentary-multiply-with-carry PRNG in Racket. I want to use provide
to restrict access only to certain functions within my library, and to impose contracts on them. Using the Racket Documentation (linked above), I have put the following code at the top of my file to that end:
(require data/queue)
(provide
(contract-out
(make-cmwc-gen (-> (listof integer?) integer? integer? integer? procedure?))
(make-default-cmwc-gen (-> integer? procedure?))
(make-cmwc-gen-raw (-> queue? integer? integer? integer? procedure?))
(init-cmwc-seed (-> integer? queue?))))
But when I run the file in DrRacket, I get the following error:
. contract-out: not a provide sub-form in: (contract-out (make-cmwc-gen (-> (listof
integer?) integer? integer? integer? procedure?)) (make-default-cmwc-gen (-> integer?
procedure?)) (make-cmwc-gen-raw (-> queue? integer? integer? integer? procedure?))
(init-cmwc-seed (-> integer? queue?)))
The code throws no errors and otherwise works when run in DrRacket without the above code inserted.
What is the proper way to restrict access only to certain functions outside of a source file as well as enforcing their contracts in Racket?
contract-out
was added in September, so if you're using it in a version older than 5.2 it won't work. Also, if you can't upgrade for some reason try usingprovide/contract
. – Asumu Takikawa