From a10d145f25dd4257dd216ea0b1e97184a29c7683 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Fri, 10 Sep 2010 13:53:45 -0400 Subject: [PATCH] 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. --- collects/tests/typed-scheme/xfail/for-inference.rkt | 6 ++++++ collects/typed-scheme/private/prims.rkt | 13 +++++++++---- .../typed-scheme/scribblings/ts-reference.scrbl | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/collects/tests/typed-scheme/xfail/for-inference.rkt b/collects/tests/typed-scheme/xfail/for-inference.rkt index 14a3a70d89..38ac335799 100644 --- a/collects/tests/typed-scheme/xfail/for-inference.rkt +++ b/collects/tests/typed-scheme/xfail/for-inference.rkt @@ -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) diff --git a/collects/typed-scheme/private/prims.rkt b/collects/typed-scheme/private/prims.rkt index f01c8b1ca1..8632a5d3d0 100644 --- a/collects/typed-scheme/private/prims.rkt +++ b/collects/typed-scheme/private/prims.rkt @@ -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) diff --git a/collects/typed-scheme/scribblings/ts-reference.scrbl b/collects/typed-scheme/scribblings/ts-reference.scrbl index 4cab071761..7044a63d26 100644 --- a/collects/typed-scheme/scribblings/ts-reference.scrbl +++ b/collects/typed-scheme/scribblings/ts-reference.scrbl @@ -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 ...+)]