[plt-scheme] super-structs and structure type descriptors

From: Dave Herman (dherman at ccs.neu.edu)
Date: Thu Jun 2 13:26:44 EDT 2005

> However, is there any reason to not meld a structure definition with it's 
> contract?  It seems to have a 
> certain syntactic appeal, like define-type from PLAI and EoPL.

What distinguishes contracts from ordinary assertions is that they 
describe a relationship between two parties; for example, a function 
contract relies on the client module satisfying the preconditions and 
the provider module satisfying the postconditions.

When something goes wrong, the contract does not just blow up; its 
"blame" system allows it to give a useful error message saying which 
party was at fault for the error.

When Matthias says you are talking about assertions, not contracts, what 
he means is that EoPL's `define-datatype' is a mechanism for checking a 
property and blowing up if the property is not satisfied, but without 
the blame annotations.

You might be interested in my struct.plt PLaneT package, which provides 
some useful general forms for defining datatypes and providing them with 
contracts. (I follow the general pattern Robby suggested: when I want 
define-datatype-like behavior, I put the data definitions in a separate 
module and provide them with contracts.)

     http://planet.plt-scheme.org/300/#struct.plt1.4

Dave



Posted on the users mailing list.