[plt-scheme] contracts in teaching languages

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Tue Oct 6 20:55:38 EDT 2009

I want to try having students use real, honest-to-goodness contracts,
just to see how it goes. I'm just about to cover booleans and
predicates, so I think it's a good time to give it a go.

I think I'm also ready to try writing a macro, so I want to do something like:

(define/c (foo arg1 arg2 arg3)
  (pred1? pred2? pred3? -> ret-pred?)

and have that convert to:

(define/contract (foo arg1 arg2 arg3)
  (-> pred1? pred2? pred3? ret-pred?) ; equivalently (pred1? pred2?
pred3? . -> . ret-pred?)

One concern is that the reader in BSL gets upset by functions in
argument positions, but I know there's a way around that, because the
universe teachpack lets you specify handlers: (on-tick mod-world),

So, can somebody explain how I'd let my re-written contract fly under
the BSL parser's radar? Obviously, if I get this working, I'll let
people know how well--or badly--it works.


Posted on the users mailing list.