[plt-scheme] More document (newbie)

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Oct 21 17:24:29 EDT 2008

On Tue, Oct 21, 2008 at 1:24 PM, Marek Kubica <marek at xivilization.net> wrote:
> The only thing that has been non-intuitive was the contracts-stuff. I
> tried playing with contracts, but haven't found a way to validate a
> data structure against a contract in the REPL. So I have skipped that
> part.

I've added something to the guide about this. The below is the new text.

hth,
Robby

All of the contracts and module in this chapter (excluding those just
following) are written using the standard #lang syntax for describing
modules. Thus, if you extract examples from this chapter in order to
experiment with the behavior of the contract system, you would have to
make multiple files.

To rectify this, PLT Scheme provides a special language, called
scheme/load. The contents of such a module is other modules (and
require statements), using the parenthesized syntax for a module. For
example, to try the example earlier in this section, you would write:

  #lang scheme/load

  (module m scheme
    (define amount 150)
    (provide/contract [amount (and/c number? positive?)]))

  (module n scheme
    (require 'm)
    (+ amount 10))

  (require 'n)

Each of the modules and their contracts are wrapped in parenthesis
with the module keyword at the front. The first argument to module
should be the name of the module, so it can be used in a subsequent
require statement (note that in the require, the name of the module
must be prefixed with a quote). The second argument to module is the
language (what would have come lang #lang in the usual notation), and
the remaining arguments are the body of the module. After all of the
modules, there must a require to kick things off.


Posted on the users mailing list.