[plt-scheme] contract questions--convention for "any" conflict and inline documentation

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Nov 21 17:52:33 EST 2008

If things go well, I hope to be able to get rid of `any' from the
contract library (by making all function contracts preserve tail
recursion).

Robby

On Fri, Nov 21, 2008 at 4:51 PM, Noel Welsh <noelwelsh at gmail.com> wrote:
> On Fri, Nov 21, 2008 at 10:39 PM, Rob Hunter <rob.hunter at gmail.com> wrote:
>> I'm new to contracts, and had a couple of questions for the community:
>>
>> (1) If I try to do a simple (require scheme/contracts), I run up
>> against a conflict with SRFI-1 "any" and the contract "any".  I'm
>> doing this right now, but was wondering if this was a common enough
>> issue that a convention has been established:
>>
>> (rename-in scheme/contract
>>                  (any c:any))
>
> Yeah, this is a pain.  By and large I've shifted to comprehensions and
> the PLT list library, so I don't run into it so often.  When I do use
> SRFI 1 I typically require it using except-in any.
>
>> (2) I like the idea of using contracts as a way of augmenting the
>> documentation of a function.  My vision is to do use a convention like
>> this for certain functions:
> ...
>>
>> This is all well and good, except that I can no longer have
>> my-great-fn in the (provide ...) form at the top of my module.  I
>> really like provide as an "always there" source of documenting what
>> this module provides.  So, I'm considering using the following
>> "comment convention", but does anyone have a better idea?
>
> I now put my provide forms at the bottom of modules, so they work
> consistently with contracts.  You can bind a name to a contract, as a
> contract is just a value:
>
> (define my-fn-contract (-> number? number?))
> (define (my-fn n)
>  (* n n))
>
> and at the bottom of the file:
>
> (provide/contract
>  [my-fn my-fn-contract])
>
> That's often too much work for me.
>
> N.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>


Posted on the users mailing list.