Move mutated-vars and poly-c libraries to unstable collection.
- add docs - change requires - fix `letrec-syntaxes+values' Fix contract on `author+email' svn: r16628
This commit is contained in:
parent
bbbb5f11e3
commit
99a70b38d8
|
@ -120,7 +120,7 @@
|
|||
|
||||
(provide/contract
|
||||
[author (->* (content?) () #:rest (listof content?) block?)]
|
||||
[author+email (-> content? string? element?)])
|
||||
[author+email (->* (content? string?) (#:obfuscate? any/c) element?)])
|
||||
|
||||
(define (author . auths)
|
||||
(make-paragraph
|
||||
|
|
|
@ -229,7 +229,7 @@ the binding (according to @scheme[free-identifier=?]) matters.}
|
|||
(id ...+ . id)
|
||||
id]]
|
||||
|
||||
A fully-expanded @tech{syntax object} corresponds to a @deftech{parse}
|
||||
A @deftech{fully-expanded} @tech{syntax object} corresponds to a @deftech{parse}
|
||||
of a program (i.e., a @deftech{parsed} program), and @tech{lexical
|
||||
information} on its @tech{identifiers} indicates the
|
||||
@tech{parse}.
|
||||
|
|
3
collects/typed-scheme/env/lexical-env.ss
vendored
3
collects/typed-scheme/env/lexical-env.ss
vendored
|
@ -3,8 +3,9 @@
|
|||
(require (except-in "../utils/utils.ss" extend))
|
||||
(require "type-environments.ss"
|
||||
"type-env.ss"
|
||||
unstable/mutated-vars
|
||||
(only-in scheme/contract ->* ->)
|
||||
(utils tc-utils mutated-vars)
|
||||
(utils tc-utils)
|
||||
(only-in (rep type-rep) Type/c)
|
||||
(except-in (types utils convenience) -> ->*))
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
mzlib/trace
|
||||
scheme/list
|
||||
(only-in scheme/contract -> ->* case-> cons/c flat-rec-contract provide/contract any/c)
|
||||
(for-template scheme/base scheme/contract (utils poly-c) (only-in scheme/class object% is-a?/c subclass?/c)))
|
||||
(for-template scheme/base scheme/contract unstable/poly-c (only-in scheme/class object% is-a?/c subclass?/c)))
|
||||
|
||||
(define (define/fixup-contract? stx)
|
||||
(or (syntax-property stx 'typechecker:contract-def)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
[remove *remove])
|
||||
(env lexical-env type-environments)
|
||||
(r:infer infer)
|
||||
(utils tc-utils mutated-vars)
|
||||
(utils tc-utils)
|
||||
(typecheck tc-envops tc-metafunctions)
|
||||
syntax/kerncase
|
||||
mzlib/trace
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
(types utils convenience)
|
||||
(private parse-type type-annotation type-contract)
|
||||
(env type-env init-envs type-name-env type-alias-env lexical-env)
|
||||
(utils tc-utils mutated-vars)
|
||||
unstable/mutated-vars
|
||||
(utils tc-utils)
|
||||
"provide-handling.ss"
|
||||
"def-binding.ss"
|
||||
(for-template
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#lang scheme/base
|
||||
|
||||
(require (for-template scheme/base)
|
||||
syntax/boundmap syntax/kerncase
|
||||
mzlib/trace)
|
||||
syntax/boundmap syntax/kerncase)
|
||||
|
||||
;; mapping telling whether an identifer is mutated
|
||||
;; maps id -> boolean
|
||||
|
@ -33,12 +32,12 @@
|
|||
(fmv/list #'b))]
|
||||
[(letrec-values ([_ e] ...) . b) (begin (fmv/list #'(e ...))
|
||||
(fmv/list #'b))]
|
||||
[(letrec-syntaxes+values _ ([_ e] ...) . b) (begin (fmv/list #'(e ...))
|
||||
(fmv/list #'b))]
|
||||
[(#%expression e) (find-mutated-vars #'e)]
|
||||
;; all the other forms don't have any expression subforms (like #%top)
|
||||
[_ (void)]))
|
||||
|
||||
;(trace find-mutated-vars)
|
||||
|
||||
;; checks to see if a particular variable is ever set!'d
|
||||
;; is-var-mutated? : identifier -> boolean
|
||||
(define (is-var-mutated? id) (module-identifier-mapping-get table id (lambda _ #f)))
|
34
collects/unstable/scribblings/mutated-vars.scrbl
Normal file
34
collects/unstable/scribblings/mutated-vars.scrbl
Normal file
|
@ -0,0 +1,34 @@
|
|||
#lang scribble/manual
|
||||
@(require scribble/eval
|
||||
(for-label unstable/mutated-vars
|
||||
scheme/contract
|
||||
scheme/base))
|
||||
|
||||
@title[#:tag "mutated-vars"]{Finding Mutated Variables}
|
||||
|
||||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require unstable/mutated-vars))
|
||||
|
||||
@defmodule[unstable/mutated-vars]
|
||||
|
||||
@author[@author+email["Sam Tobin-Hochstadt" "samth@ccs.neu.edu"]]
|
||||
|
||||
|
||||
@defproc[(find-mutated-vars [stx syntax?]) void?]{ Traverses
|
||||
@scheme[stx], which should be @scheme[module-level-form] in the sense
|
||||
of the grammar for
|
||||
@tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{fully-expanded} forms,
|
||||
and records all of the variables that are mutated.}
|
||||
|
||||
@defproc[(is-var-mutated? [id identifier?]) boolean?]{
|
||||
Produces @scheme[#t] if @scheme[id] is mutated by an expression
|
||||
previously passed to @scheme[find-mutated-vars], otherwise
|
||||
produces @scheme[#f].
|
||||
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(find-mutated-vars #'(begin (set! var 'foo) 'bar))
|
||||
(is-var-mutated? #'var)
|
||||
(is-var-mutated? #'other-var)
|
||||
]
|
||||
}
|
32
collects/unstable/scribblings/poly-c.scrbl
Normal file
32
collects/unstable/scribblings/poly-c.scrbl
Normal file
|
@ -0,0 +1,32 @@
|
|||
#lang scribble/manual
|
||||
@(require scribble/eval
|
||||
(for-label unstable/poly-c
|
||||
scheme/contract
|
||||
scheme/base))
|
||||
|
||||
@title[#:tag "poly-c"]{Anaphoric Contracts}
|
||||
|
||||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require unstable/poly-c scheme/contract))
|
||||
|
||||
@defmodule[unstable/poly-c]
|
||||
|
||||
@author[@author+email["Sam Tobin-Hochstadt" "samth@ccs.neu.edu"]
|
||||
@author+email["Carl Eastlund" "cce@ccs.neu.edu" #:obfuscate? #t]]
|
||||
|
||||
|
||||
@defform[(poly/c ([id+ id-] ...) cnt)]{
|
||||
Creates an ``anaphoric'' contract, using the @scheme[id+ ...] as the
|
||||
positive positions, and the @scheme[id- ...] as the negative positions.
|
||||
|
||||
Anaphoric contracts verify that only values provided to a given
|
||||
positive position flow out of the corresponding negative position.
|
||||
|
||||
@examples[#:eval the-eval
|
||||
(define/contract (f x) (poly/c ([in out]) (in . -> . out))
|
||||
(if (equal? x 17) 18 x))
|
||||
(f 1)
|
||||
(f #f)
|
||||
(f 17)
|
||||
]
|
||||
}
|
|
@ -80,6 +80,8 @@ Keep documentation and tests up to date.
|
|||
@include-section["string.scrbl"]
|
||||
@include-section["struct.scrbl"]
|
||||
@include-section["syntax.scrbl"]
|
||||
@include-section["poly-c.scrbl"]
|
||||
@include-section["mutated-vars.scrbl"]
|
||||
|
||||
@;{--------}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user