[plt-scheme] procedure instrospection

From: Jose A. Ortega Ruiz (jao at gnu.org)
Date: Sat Apr 18 04:48:37 EDT 2009

Eli Barzilay <eli at barzilay.org> writes:


> But the name for the "optional" in the above is `b'...  I've put
> "optional" in quotes since it doesn't have to be an optional argument,
> it can be anything, and can have behavior that is not related to the
> other cases in the `case-lambda' form (that's why I used different
> strings in the above).  The resulting arities can also be arbitrary,
> for example:
>   (case-lambda [(x) 1]
>                [(a b c) 2]
>                [(i j k l m) 3])
> has an arity list of (1 3 5), which cannot be described with such an
> `#:optional'.

OK, i see your point now. what about something like:

(foo [x] [a b c] [i j k l m])


(foo [(x) (a b c) (i j k l m)])


> Here's another random example from the texpict collection:
>   (define inset/clip
>     (case-lambda
>      [(p l t r b) ...]
>      [(p h v) (inset/clip p h v h v)]
>      [(p a)   (inset/clip p a a a a)]))

one could even try to be smart and share common prefixes:

(insert/clip p [l t r b] [h v] [a])

does that make sense?

Posted on the users mailing list.