From da31c3f9a26b230f32f65b44ae9c592e55b9bde6 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Fri, 6 Aug 2010 12:21:50 -0400 Subject: [PATCH] Documented TR's behavior on literals. original commit: 201aaa9090b3aeedc0454bdd575565f8764ef2c8 --- .../scribblings/optimization.scrbl | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/collects/typed-scheme/scribblings/optimization.scrbl b/collects/typed-scheme/scribblings/optimization.scrbl index 20073dc9..4f82a1ab 100644 --- a/collects/typed-scheme/scribblings/optimization.scrbl +++ b/collects/typed-scheme/scribblings/optimization.scrbl @@ -54,7 +54,9 @@ Typed Racket's optimizer can optimize the latter program to use former program. Thus, to get the most of Typed Racket's optimizer, you should use the -@racket[Float] type when possible. +@racket[Float] type when possible. For similar reasons, you should use +floating-point literals instead of exact literals when doing +floating-point computations. On a similar note, the @racket[Inexact-Complex] type is preferable to the @racket[Complex] type for the same reason. Typed Racket can keep @@ -68,6 +70,21 @@ represent @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{complex numbers} as two @tech[#:doc '(lib "scribblings/reference/reference.scrbl")]{real numbers}. +As with floating-point literals, +@tech[#:doc '(lib "scribblings/reference/reference.scrbl") #:key +"inexact numbers"]{inexact} +@tech[#:doc '(lib "scribblings/reference/reference.scrbl") #:key +"complex numbers"]{complex} +literals (such as @racket[1.0+1.0i]) should be preferred over exact +@tech[#:doc '(lib "scribblings/reference/reference.scrbl") #:key +"complex numbers"]{complex} +literals (such as @racket[1+1i]). Note that both parts of a literal must be +present and +@tech[#:doc '(lib "scribblings/reference/reference.scrbl") #:key +"inexact numbers"]{inexact} +for the literal to be of type +@racket[Inexact-Complex]; @racket[0.0+1.0i] is of type +@racket[Inexact-Complex] but @racket[+1.0i] is not. To get the most of Typed Racket's optimizer, you should also favor rectangular coordinates over polar coordinates.