[plt-scheme] passing-on keyword arguments
Thanks, Eli. I used your suggestion and it worked for me purposes.
--rob
On Tue, Mar 18, 2008 at 3:53 PM, Eli Barzilay <eli at barzilay.org> wrote:
> On Mar 18, Rob Hunter wrote:
> > Let me elaborate: If, for example, I had a way of passing an
> > "absent" value for a keyword argument, then I could do this with
> > functions:
> >
> > (define (inner #:x [x 10]) (* x x))
> >
> > (define (outer #:x [x ABSENT-VAL]) (+ (inner #:x x) 5))
> >
> > The semantics of ABSENT-VAL are such that if it is passed as a
> > keyword argument's val, then it as if I never set that keyword arg,
> > and thus the default value for it would be used.
>
> It's a cute idea, but it only covers one corner. Specifically in this
> case, I think that another goal should be to avoid repeating `inner's
> interface. There is a way to do that now, but it's not convenient:
>
> (define outer
> (make-keyword-procedure
> (lambda (kws vals . args)
> (+ (keyword-apply inner kws vals args) 5))))
>
> I think that I know how to make it easier, allowing something like
> this:
>
> (define (outer args ...)
> (+ (inner args ...) 5))
>
> to do the same, but it'll take some work to implement.
>
> --
> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
> http://www.barzilay.org/ Maze is Life!
>