b0VIM 7.2I Etovasnwer.home~tov/projects/research/affine-contracts/planet/affine-contracts/manual.scrblutf-8 3210#"! UtpZ [adgCk! R  f  U T  l  @ ^%$t%jhg>D^\[54U;98 Y@defproc[(affine-box/c [c contract?]) contract?]{} negative party. then reading it more then once is a contract violation by the (say, using @scheme[provide/contract] and @scheme[affine-box/c]), If the affine box has been wrapped by an affine box contract Gets the value in an affine box.@defproc[(affine-unbox [b affine-box?]) any/c]{} Predicate for affine boxes.@defproc[(affine-box? [v any/c]) boolean?]{} @scheme[affine-box/c].) until it has been wrapped by an affine box contract by (Note that an affine box may be unboxed an unlimited amount of time Creates a new affine box containing @scheme[v].@defproc[(affine-box [v any/c]) affine-box?]{@section[#:tag "boxes"]{Affine Boxes}} and range in the style of @scheme[->*]. Produces a contract for a one-shot function with the given domain@defform[#:id -o* (-o* (mandatory-dom ...) (optional-dom ...) rest range)]{} and range in the style of @scheme[->]. Produces a contract for a one-shot function with the given domain any])]{ (values range-expr ...) [range range-expr (keyword dom-expr)] ([dom dom-expr@defform/subs[#:id -o (-o dom ... range)} @scheme[require]d the abused procedure. error blames the negative party — that is, the module that procedure to be applied once. If it is applied further times, a contract checks immediately that the value is a @scheme[procedure?], and allows the A contract for a function that can be applied at most once. The contract contract?]{@defthing[affine-procedure/c@section[#:tag "procedures"]{Affine Procedures}the library responsible for the aliasing will be blamed.responsible not to alias those boxes before passing them back; otherwise,produce and consume affine boxes, and a client of that library will then bethe value once unboxed. However, a library may provide functions that bothunboxed (dereferenced) only once. Obviously this does nothing to protectfor non-procedural values by wrapping them in opaque boxes which may beto add behavior for when they are "used." Thus, we support affine contractsbeen applied before. Arbitrary values, however, do not necessary have a wayto wrap them to get additional behavior, such as checking that they have notgeneral values. Because procedures have behavior when applied, it is possibleThe package supports two kinds of affine contracts: for procedures, and forcontext of the PLT Scheme contract system.within a module. We believe this is the appropriate way to do things in theby way of @scheme[provide/contract], but they do nothing to enforce affinityexported by this package allow imposing affine constraints on other modulesfor whatever must be done to preserve invariants). The contract combinatorsresponsible for correct single-threading within the modules that they write (ortheir libraries from multiple uses. We assume that the author of a library isThis package allows library authors to protect affine values provided from@section[#:tag "concept"]{The Main Idea}For license information, please see the file @tt{LICENSE}. ICFP’09.for Affine Types” by Jesse A. Tov and Riccardo Pucella, as submitted toThis package provides affine contracts, based on the paper “Affine Contractsby @author+email["Jesse Tov" "tov@ccs.neu.edu"]@title[#:tag "top"]{Affine Contracts} (this-package-in main.ss))] scheme/contract@require[(for-label scheme/base scribble/basic] scribb scr scribble/manual@@require[scribble/manual#lang scribble/docad x2 } ] (provide/contract [f (string? . -> . (affine-box/c number?))]) @schemeblock[ we could write: that takes a string and returns a one-shot box containing a number, contents of the box. For example, to provide a function @scheme[f] Produces a contract for an affine box, given a contract for thead?ZkjDCy\[   0 G 5 L m ! RQ! RkL"qHFEba3hfe9B@@defpr@defproc[(affine@d@@@defproc[(affine-box/c [c contract?]) contract?]{} negative party. then reading it more then once is a contract violation by the (say, using @scheme[provide/contract] and @scheme[affine-box/c]), If the affine box has been wrapped by an affine box contract Gets the value in an affine box.@defproc[(affine-unbox [b affine-box?]) any/c]{} Predicate for affine boxes.@defproc[(affine-box? [v any/c]) boolean?]{} @scheme[affine-box/c].) until it has been wrapped by an affine box contract by (Note that an affine box may be unboxed an unlimited amount of time Creates a new affine box containing @scheme[v].@defproc[(affine-box [v any/c]) affine-box?]{@section[#:tag "boxes"]{Affine Boxes}} and range in the style of @scheme[->*]. Produces a contract for a one-shot function with the given domain@defform[#:id -o* (-o* (mandatory-dom ...) (optional-dom ...) rest range)]{} and range in the style of @scheme[->]. Produces a contract for a one-shot function with the given domain any])]{ (values range-expr ...) [range range-expr (keyword dom-expr)] ([dom dom-expr@defform/subs[#:id -o (-o dom ... range)} @scheme[require]d the abused procedure. error blames the negative party — that is, the module that procedure to be applied once. If it is applied further times, a contract checks immediately that the value is a @scheme[procedure?], and allows the A contract for a function that can be applied at most once. The contract contract?]{@defthing[affine-procedure/c@section[#:tag "procedures"]{Affine Procedures}the library responsible for the aliasing will be blamed.responsible not to alias those boxes before passing them back; otherwise,produce and consume affine boxes, and a client of that library will then bethe value once unboxed. However, a library may provide functions that bothunboxed (dereferenced) only once. Obviously this does nothing to protectfor non-procedural values by wrapping them in opaque boxes which may beto add behavior for when they are "used." Thus, we support affine contractsbeen applied before. Arbitrary values, however, do not necessary have a wayto wrap them to get additional behavior, such as checking that they have notgeneral values. Because procedures have behavior when applied, it is possibleThe package supports two kinds of affine contracts: for procedures, and forcontext of the PLT Scheme contract system.within a module. We believe this is the appropriate way to do things in theby way of @scheme[provide/contract], but they do nothing to enforce affinityexported by this package allow imposing affine constraints on other modulesfor whatever must be done to preserve invariants). The contract combinatorsresponsible for correct single-threading within the modules that they write (ortheir libraries from multiple uses. We assume that the author of a library isThis package allows library authors to protect affine values provided from@section[#:tag "concept"]{The Main Idea}@declare-exporting[affine-contracts/main]For license information, please see the file @tt{LICENSE}. ICFP’09.for Affine Types” by Jesse A. Tov and Riccardo Pucella, as submitted toThis package provides affine contracts, based on the paper “Affine Contractsby @author+email["Jesse Tov" "tov@ccs.neu.edu"]@title[#:tag "top"]{Affine Contracts} "main.ss")] scheme/contract@require[(for-label scheme/base scribble/basic] scribble/eval