[plt-dev] abstract contracts

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Sep 5 11:02:12 EDT 2009

Is there a stack? predicate afterwards?

On Sep 4, 2009, at 2:00 PM, Robby Findler wrote:

> I've added #:exists to provide/contract, as a way to hide information
> ala "type t" declarations on ML signatures.
>
> See the contracts section in the Guide for a worked example and a
> discussion of a gotcha. The short version is that you can now write
> things like this:
>
> (provide/contract
>  #:exists stack
>  [new stack]
>  [push (-> int stack stack)]
>  [pop (-> (and/c stack non-empty?) int)]
>  [non-empty? (-> stack boolean?)])
>
> and have the contract system enforce data abstraction, even if your
> stack operations are simply these:
>
>  (define new '())
>  (define push cons)
>  (define pop car)
>  (define non-empty? pair?)
>
> That is, clients of your module will not be able to treat your stacks
> as if they were lists, even though they really are lists.
>
> Robby
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-dev



Posted on the dev mailing list.