Added annotated versions of the for macros that generate vectors.

They are purposedly left out of the documentation since the typchecker
can't currently handle their expansion.
This commit is contained in:
Vincent St-Amour 2010-09-10 13:53:45 -04:00
parent 65c502f9d7
commit a10d145f25
3 changed files with 17 additions and 4 deletions

View File

@ -79,3 +79,9 @@
(for/and: : Boolean
((i : Exact-Positive-Integer '(1 2 3)))
(< i 3))
;; for/vector: would need stronger inference. same for for*/vector and
;; both flvector variants
(for/vector: : (Vectorof Integer)
((x : Integer (in-range 10)))
x)

View File

@ -33,6 +33,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
(rename-in racket/contract [-> c->])
"base-types.rkt"
"base-types-extra.rkt"
racket/flonum ; for for/flvector and for*/flvector
(for-syntax
syntax/parse
syntax/private/util
@ -511,8 +512,8 @@ This file defines two sorts of primitives. All of them are provided into any mod
(quasisyntax/loc
stx
(begin (define-syntax name (define-for-variant #'untyped-name)) ...))]))
;; for/hash{,eq,eqv}:, for/and:, for/first: and for/last:'s expansions
;; can't currently be handled by the typechecker.
;; for/hash{,eq,eqv}:, for/vector:, for/flvector:, for/and:, for/first: and
;; for/last:'s expansions can't currently be handled by the typechecker.
;; They have been left out of the documentation.
(define-for-variants
(for/list: for/list)
@ -522,7 +523,9 @@ This file defines two sorts of primitives. All of them are provided into any mod
(for/and: for/and)
(for/or: for/or)
(for/first: for/first)
(for/last: for/last))
(for/last: for/last)
(for/vector: for/vector)
(for/flvector: for/flvector))
;; Unlike with the above, the inferencer can handle any number of #:when
;; clauses with these 2.
@ -595,7 +598,9 @@ This file defines two sorts of primitives. All of them are provided into any mod
(for*/and: for*/and)
(for*/or: for*/or)
(for*/first: for*/first)
(for*/last: for*/last))
(for*/last: for*/last)
(for*/vector: for*/vector)
(for*/flvector: for*/flvector))
(define-for-syntax (define-for*-folding-variant name)
(lambda (stx)

View File

@ -309,6 +309,8 @@ the return type of a @racket[for] form is optional. Unlike
@;@defform[(for/hash: : u (for:-clause ...) expr ...+)] @; the ones that are commented out don't currently work
@;@defform[(for/hasheq: : u (for:-clause ...) expr ...+)]
@;@defform[(for/hasheqv: : u (for:-clause ...) expr ...+)]
@;@defform[(for/vector: : u (for:-clause ...) expr ...+)]
@;@defform[(for/flvector: : u (for:-clause ...) expr ...+)]
@;@defform[(for/and: : u (for:-clause ...) expr ...+)]
@defform[(for/or: : u (for:-clause ...) expr ...+)]
@;@defform[(for/first: : u (for:-clause ...) expr ...+)]