[racket] Weird typed racket error

From: Alexander D. Knauth (alexander at knauth.org)
Date: Sat Apr 19 23:02:19 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.

Then how do the functions in the plot/typed library work?  They use keyword arguments, right?  Why would keyword arguments work for them and not for my sphere3d?  

> Also FWIW, in Typed Racket, vectors are annoying function arguments because their types are invariant; i.e. because vectors are mutable, a (Vectorof Integer) isn't also a (Vectorof Real). To use the `sphere3d` function, I had to explicitly instantiate the #:posn argument's type:
> 
>    (plot3d (sphere3d #:posn ((inst vector Real) 0 0 0) #:r 2))
> 
> When it was (vector 0 0 0), TR made it a (Vectorof Integer) and raised a type error.
> 
> It would be great if we had types and functions for operating on immutable vectors. Until then, it's best to use lists or your own immutable structures.

I wanted to use vectors so that I could use things like v+ from plot/utils (or plot/typed/utils).  

But you can still use (ann (vector 0 0 0) (Vectorof Real)), right?  




Posted on the users mailing list.