[plt-dev] Typed Scheme: function type declarations should support optional args
On Mon, Mar 29, 2010 at 9:31 AM, Noel Welsh <noelwelsh at gmail.com> wrote:
> This common pattern
>
> (define (foo a [b 1] [c 2] [d 3]) ...)
>
> which expands into a case-lambda like
>
> (define foo
> (case-lambda (([a] (foo a 1 2 3))
> ([a b] (foo a b 2 3)) ...))
>
> is a damn pain to type and Type in Typed Scheme. It would be really
> nice it one could just write:
>
> (: foo (Integer [Integer] [Integer] [Integer] -> Integer))
> (define (foo a [b 1] [c 2] [d 3]) ...)
>
> in Typed Scheme.
Wouldn't it though ...
Really, there are two separate issues here - a convenient syntax for
types with optional arguments, and support for defining functions with
optional arguments. The first is less of a pain, but probably
something I could implement pretty easily. Unfortunately, the second
is significantly harder, because the expansion of such definitions is
quite convoluted. As a short-term work-around, you can use
`opt-lambda' from `mzlib/etc', whose expansion is much simpler.
--
sam th
samth at ccs.neu.edu