Subject: Re: DEFSTRUCT Facility for Scheme (was Re: Java/Lisp Language Evolution Correlates)
From: (Rob Warnock)
Date: 2000/06/19
Newsgroups: comp.lang.scheme
Message-ID: <8ijtc7$86fp$>
Christopher Browne <> 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

	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
	    [(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 Warnock, 41L-955
Applied Networking
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043