[racket] Typed racket and keywords

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Thu Feb 21 10:20:08 EST 2013

I agree, the docs could be a lot clearer.

I'll add examples that use keyword arguments.

Thanks for the report!

Vincent



At Thu, 21 Feb 2013 09:18:39 +0000,
Norman Gray wrote:
> 
> 
> Neil, hello.
> 
> On 2013 Feb 21, at 03:49, Neil Toronto <neil.toronto at gmail.com> wrote:
> 
> > Well, you can't do it like that, but you can like this:
> > 
> > #lang typed/racket
> > 
> > (: test0 (Integer [#:zero Integer] -> Boolean))
> > (define (test0 x #:zero [v 0])
> >  (= x v))
> 
> Aha -- that's certainly a neater way of doing it.  Thanks!
> 
> There may be a documentation lacuna, however, since that form seems to be not straightforwardly deducible from the Typed Racket reference (v5.3.3).
> 
> Section 1.6, Other Type Constructors <http://docs.racket-lang.org/ts-reference/type-ref.html#%28part._.Other_.Type_.Constructors%29>, describes four forms of function type, but doesn't include any optional arguments (I presumed that such optional parts had to be typed explicitly with case->).  'dom' isn't defined there (I guessed it could refer only to an individual type), and the 'dom' of <http://docs.racket-lang.org/reference/function-contracts.html> doesn't match.  Even the 'optional-dom' of the ->* description doesn't fit the form above.
> 
> Similarly, the opt-lambda: of <http://docs.racket-lang.org/ts-reference/special-forms.html#(part._.Anonymous_.Functions)> includes optional arguments, but doesn't appear to permit keywords.
> 
> The (Integer [#:zero Integer] -> Boolean) form is pretty intuitive, though, and I should have experimented more, but I confess to being an incorrigible obsessive about manuals (new fridge, new phone: "Oh, look, what nice manual, I'll turn the gadget on later...").
> 
> All the best,
> 
> Norman
> 
> 
> -- 
> Norman Gray  :  http://nxg.me.uk
> SUPA School of Physics and Astronomy, University of Glasgow, UK
> 
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.