Hi guys,
Apparently, with a desire to use keywords more in functions, I’ll have to wrap 
my head around keyword-apply better. Two questions I have are:

1. Why must the  kw-lst  be sorted in keyword<? rather than having those 
arguments appear in any order that makes sense to the caller, and then having 
keyword-apply sort both kw-lst and kw-val-lst appropriately to keep the 
key/value pairs synchronized?

2. The reference says:

(keyword-apply proc
                                kw-lst
                                kw-val-lst
                                v …
                                lst
                                #:<kw> kw-arg …)

After playing around a bit all of the following are equivalent:

(define (bar #:x x #:y y #:z z u v . w) (list x y z u v w))

(keyword-apply bar '() '() '(6 7 8 9 10) #:x 3 #:y 4 #:z 5)
(keyword-apply bar '(#:x #:y #:z) '(3 4 5) '(6 7 8 9 10))
(keyword-apply bar #:x 3 #:y 4 #:z 5 '() '() '(6 7 8 9 10))
(keyword-apply bar #:z 5 #:y 4 #:x 3 '() '() '(6 7 8 9 10))
(keyword-apply bar #:z 5 #:x 3 '(#:y) '(4) '(6 7 8 9 10))
(keyword-apply bar #:z 5 #:x 3 '(#:y) '(4) 6 7 '(8 9 10))

So it appears that ordering of keywords is only mandatory in the kw-lst. What’s 
the advantage to using the kw-lst/kw-val-lst? If those lists are primarily 
built using automation, rather than by hand, then question #1 is probably 
explained by the idea that the automation is expected to sort the keywords 
prior to the call?

-Kevin
____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to