[plt-scheme] procedure instrospection

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Apr 18 14:17:24 EDT 2009

On Apr 18, Jose A. Ortega Ruiz wrote:
> 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])
> 
> or
> 
> (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?

[Yes -- but that's a presentation issue.  My point was that there are
all of these additional considerations to make.]

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.