[plt-scheme] define/contract

From: Neil W. Van Dyke (neil at neilvandyke.org)
Date: Mon Mar 24 08:17:06 EST 2003

While looking at contracts as a documentation aid, especially for
eliminating some redundant informal specification in embedded
documentation...

Would `define/contract' -- a syntactic convenience for putting the
contract alongside the value and the name to which it's bound -- be a
good thing, and easily doable with the module system syntax?

For example:

    (module moo mzscheme
      (define/contract foo
        <contract1>
        <value1>)
      (define/contract bar
        <contract2>
        <value2>)
      (provide-all-defined)))

    =equiv=>

    (module moo mzscheme
      (define foo
        <value1>)
      (define bar
        <value2>)
      (provide/contract (foo <contract1>)
                        (bar <contract2>)))

Aside: Eventually, I'd like to build on this with `define/contract/doc'
(or `define/c/d'), though I want to wait on that til I have time to
design an embedded doc language with which I'm reasonably happy (I don't
even like my own Texinfo-derived doc language, Funcelit).  Using
contracts to generate part of the docs seems to be low-hanging fruit,
however, and independent of any doc language.

-- 
                                             http://www.neilvandyke.org/


Posted on the users mailing list.