[plt-scheme] contracts and structure subtypes?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Sun May 23 18:22:38 EDT 2004

Oops -- copied an early version of the docs. Here's a revised version
of the main paragraph below.

  If the struct has a parent, the second \scheme|struct| form (above)
  must be used, with the first name referring to the struct itself and
  the second name referring to the parent struct. Unlike
  \scheme|define-struct|, however, all of the fields (and their
  contracts) must be listed. The contract on the fields that the
  sub-struct shares with its parent are only used in the contract for
  the sub-struct's maker (not the selector or mutators).

Robby

At Sun, 23 May 2004 17:19:32 -0500, Robby Findler wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> This has been on my list of things to do for some time now. Thanks for
> the prodding. The v299-tagged version of contracts now supports parent
> structs (299 is very much still a work in progress, so you may have to
> wait a while before this becomes useful to you).
> 
> Here are the revised docs:
> 
>   p/c-item :==
>   (struct identifier ((identifier contract-expr) ...))
>   (struct (identifier identifier) ((identifier contract-expr) ...))
>   ... and the old stuff ...
> 
>   The \scheme|struct| form of a \scheme|provide/contract| clause
>   provides a structure definition. Each field has a contract that
>   dictates the contents of the fields.
> 
>   If the struct has a parent, the second \scheme|struct| form (above)
>   must be used, with the first name referring to the first struct and
>   the second name referring to the second one. Unlike
>   \scheme|define-struct|, however, all of the fields (and their
>   contracts) must be listed. The contract on the sub-structs common
>   fields are only used in the contract for the sub-struct's maker (but
>   not the selector or mutators).
> 
>   Note that the struct definition must come before the provide clause
>   in the module's body.
> 
> Robby



Posted on the users mailing list.