Can't he write a macro that unfolds into a type specification, at least for his uses?



On Mar 29, 2010, at 9:44 AM, Sam Tobin-Hochstadt wrote:

On Mon, Mar 29, 2010 at 9:31 AM, Noel Welsh <noelwe...@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
sa...@ccs.neu.edu
_________________________________________________
 For list-related administrative tasks:
 http://list.cs.brown.edu/mailman/listinfo/plt-dev

_________________________________________________
 For list-related administrative tasks:
 http://list.cs.brown.edu/mailman/listinfo/plt-dev

Reply via email to