[plt-scheme] keyword arguments (in v4.0, maybe)

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Jun 12 02:58:22 EDT 2007

At Tue, 12 Jun 2007 11:48:17 +0800, Matthew Flatt wrote:
> The new guide and reference document the possible changes. See
> especially sections 4.3 and 4.4 in the new guide; here's a starting
> point (in a temporary copy on my web site):
> 
>   http://www.cs.utah.edu/~mflatt/tmp/newdoc/guide/scheme-forms.html

Based on a few pieces of mail that I've received off-list, I think I
should have mentioned the following bits from the documentation:


 * `make-keyword-procedure' let you have "rest" keyword arguments.

 * `keyword-apply' is like `apply', but also accepts a separate
   list of by-keyword arguments.


 (define (trace-wrap f)
    (make-keyword-procedure
     (lambda (kw-args . rest)
       (printf "Called with ~s ~s\n" kw-args rest)
       (keyword-apply f kw-args rest))))

  > ((trace-wrap greet) "John" #:hi "Howdy")
  Called with ((#:hi . "Howdy")) ("John")
  "Howdy, John Smith"


Matthew



Posted on the users mailing list.