Kent M Pitman <pitman@world.std.com> wrote:
+---------------
| It's obviously the case that Schemers could write a rest list and use
| (adjoin-dispenser 'test equal? 'key identity)
+---------------
This is exactly what Elk [a Scheme] does with it's X binding. Sample code
clipped from a simple Xlib app:
(let* ((dpy (open-display))
(black (black-pixel dpy)) (white (white-pixel dpy))
(width (list-ref geom 0)) (height (list-ref geom 1))
(win (create-window 'parent (display-root-window dpy)
'width width 'height height
'x (list-ref geom 2) 'y (list-ref geom 3)
'background-pixel white
'border 0
'event-mask '(exposure)))
(gc (create-gcontext 'window win 'function 'xor
'background black 'foreground white))
...and-so-on... )
...the-main-app... )
There's a utility routine "apply-with-keywords" that matches the &rest list
with a pattern of required positional args (and their defaults), and then
calls the underlying primitive [written in C] with purely positional args.
E.g., for the "create-window" call above, the glue routine [with some added
annotations] is:
(define (create-window . args)
(apply-with-keywords
'create-window ; for error messages
xlib-create-window ; underlying primitive
; positional args required by underlying primitive:
'((parent) (x 0) (y 0) (width) (height) (border 2))
; table of additional permitted optionals:
'set-window-attributes set-window-attributes-slots
args))
Yes, a bit hacky, but once it's in place you *can* use keyword-style
calls pretty much anywhere they make sense...
+---------------
| and even then they could leave out arguments they didn't want, but
| the language doesn't offer anything to encourage them to do it, which
| means it will be too much trouble for some, too hard to remember
| for others, and potentially irregularly done (e.g., varying in
| calling details on a per-facility or per-author basis).
+---------------
Agreed. Had I not seen how Elk does it in its X binding, I probably
would have continued to avoid the "keyword" style. But now, having
been given one well-worked-out example...
-Rob
-----
Rob Warnock, 8L-855 rpw3@sgi.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. FAX: 650-933-0511
Mountain View, CA 94043 PP-ASEL-IA