[racket] Weird typed racket error

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sat Apr 19 23:43:12 EDT 2014

On Apr 19, 2014, at 10:44 PM, Neil Toronto <neil.toronto at gmail.com> wrote:

> That is weird. It works in the nightly build without annotating anything but `sphere3d`, and likely in the next release as well. Keyword arguments haven't been all that well-supported in the past, so I'd try making the arguments to sphere3d positional instead.
Making ctr-posn and r positional arguments solved the problem:
(: sphere3d ((Vectorof Real) Nonnegative-Real [#:color Plot-Color] -> renderer3d))
(define (sphere3d ctr.posn r #:color [color "black"])
  (let: ([ctr.x : Real (vector-x ctr.posn)]
         [ctr.y : Real (vector-y ctr.posn)]
         [ctr.z : Real (vector-z ctr.posn)])
    (isosurface3d (λ: ([x : Real] [y : Real] [z : Real])
                    (let: ([posn : (Vectorof Real) (vector x y z)])
                      (vmag^2 (v- posn ctr.posn))))
                  (ann (sqr r) Real)
                  (ann (- ctr.x r) (U Real False)) (ann (+ ctr.x r) (U Real False))
                  (ann (- ctr.y r) (U Real False)) (ann (+ ctr.y r) (U Real False))
                  (ann (- ctr.z r) (U Real False)) (ann (+ ctr.z r) (U Real False))
                  #:line-style 'transparent
                  #:color color)))

So is it that it can handle optional keyword arguments but not mandatory keyword arguments?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140419/be392afe/attachment.html>

Posted on the users mailing list.