[racket-dev] Release for v5.0.2 has begun

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Oct 25 14:05:01 EDT 2010

On Mon, Oct 25, 2010 at 11:28 AM, Doug Williams
<m.douglas.williams at gmail.com> wrote:
> I had always assumed that case-lambda just checked alternatives in order
> until one matched - like a cond. But, that was just an assumption on my part
> and subject to being absolutely wrong. [But, if it is correct I would expect
> case-> to allow overlapping contracts.]

That is correct. Unfortunately, it gets more complex with contracts,
since each contract matches a set of arities, not just a single arity
(in the function call case, you always have a specific number of
arguments at the call site). So you'd have to either postpone the
decision about how to compose the contracts until the callsite comes
or figure out how to kind of pull the contracts apart and put them
back together in sometimes a complex way.

For example, say you have these contracts put together:

(case-> (-> integer? any)
        (-> integer? integer? integer? any)
        (->* () #:rest (listof boolean?) any))

then zero, two, and four-or-more all go to the last case, but figuring
out that you could have written this:

(case-> (-> any)
        (-> integer? any)
        (-> boolean? boolean? any)
        (-> integer? integer? integer? any)
        (->* (boolean? boolean? boolean? boolean?) #:rest (listof
boolean?) any))

is not so easy for us (especially since the #:rest argument is kind of hidden).

> Another thing I just noticed is that the documentation says that case-lambda
> is provided by scheme/base and scheme - and doesn't mention racket/base or
> racket. To me that implies that isn't available in the racket language, but
> I'm sure it is. Is that a documentation error? But lambda says the same
> thing, so I guess it is a misinterpretation on my part of what scheme versus
> racket means in the docs.

I'm seeing racket/base and racket, not scheme/base and scheme. Either
way, that seems problematic.

Robby


Posted on the dev mailing list.