[plt-scheme] Questions about contracts

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Apr 16 08:44:40 EDT 2007

On 4/16/07, Noel Welsh <noelwelsh at yahoo.com> wrote:
> It would be useful to be able to add optional messages to
> contracts, like you can do with checks in SchemeUnit.

You mean a message that says what happened when a contract fails? The
little I can offer you at the moment is to define a predicate with a
particular name. that name will be reported in the error message. Its
not much, but it isn't nothing.

> It would also be useful to have an API for destructuring contracts.

I'm not sure what structure you think there is to get! All that there
is, is a projection (well, and source location information, etc).
there is no way to, say, given a contract, ask if it was built from
case-> or ->, say, except to get its name and inspect that (and even
that normalizes things in some cases).

> If these two features we added then a fair amount of code I deal with would disappear!  I'm not just talking about SchemeUnit; in our web apps we write lots of validation code that essentially duplicates what contracts do (with these additional features).  E.g. to check a student record is valid:

Why not just abstract over contracts/warning-generation/whatever?

Robby


Posted on the users mailing list.