Christopher Browne <cbbrowne@hex.net> wrote:
+---------------
| The idea of having keyword and optional arguments would be a very
| nice thing; it would allow diminishing the number of functions
| required to implement a system in Scheme...
+---------------
For optionals, at least, MzScheme has a neat "case-lambda" form
<URL:http://www.cs.rice.edu/CS/PLT/packages/doc/mzscheme/node22.htm>:
The case-lambda form creates a procedure that dispatches to a
particular body of expressions based on the number of arguments
it receives. This provides a mechanism for creating variable-arity
procedures with more control and efficiency than using a
``rest arg'' -- e.g., the x in (lambda (a . x) ...) -- with a
lambda expression.
...
(define f
(case-lambda
[(x) x]
[(x y) (+ x y)]
[(a . any) a]))
(f 1) ; => 1
(f 1 2) ; => 3
(f 4 5 6 7) ; => 4
(f) ; raises exn:application:arity
-Rob
-----
Rob Warnock, 41L-955 rpw3@sgi.com
Applied Networking http://reality.sgi.com/rpw3/
Silicon Graphics, Inc. Phone: 650-933-1673
1600 Amphitheatre Pkwy. PP-ASEL-IA
Mountain View, CA 94043