[plt-scheme] make-mixin-contract

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed May 27 07:09:11 EDT 2009

make-mixin-contract does not guarantee that the output is okay. It is
much like what you describe, tho, with the additional guarantee that
the result of the function is a subclass of the input. So feel free to
use your contract -- whatever best suits your needs.

Robby

On Wed, May 27, 2009 at 4:54 AM, David Brooks <djb at untyped.com> wrote:
> Hi all,
>
> I'm writing some mixins and wish to provide contracts for them. I have a
> scenario like:
>
> (interface a<%> () aa)
> (interface b<%> () bb)
>
> (mixin (a<%>) (a<%> b<%>) ...)
>
> so I want a contract that checks that:
> [1] the input is class implementing a<%>;
> [2] the output is a class implementing a<%> and b<%>;
>
> I believe I can do this using implementation?/c in a function contract:
>
> (-> (implementation?/c a<%>)
>    (and/c (implementation?/c a<%>) (implementation?/c b<%>)))
>
> However, then I found make-mixin-contract, and figured I should be using
> that instead:
>
> http://docs.plt-scheme.org/reference/Object_and_Class_Contracts.html#(def._((lib._scheme/class..ss)._make-mixin-contract))
>
>> (make-mixin-contract type ...) → contract?
>>   type : (or/c class? interface?)
>> Produces a function contract that guarantees the input to the function is
>> a class that implements/subclasses each type, and that the result of the
>> function is a subclass of the input.
>>
>
> My problem is that make-mixin-contract only seems to deal with the input
> types. How should I specify the extra output types? Am I just
> misunderstanding the purpose of make-mixin-contract?
>
> Cheers,
> D
> --
> David Brooks
> http://www.untyped.com
>
>
>
>
>
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.