~ chicken-core (master) /manual/Module (scheme case-lambda)
Trap1[[tags: manual]]2[[toc:]]34== Module (scheme case-lambda)56<macro>(case-lambda <clause> ...)</macro>78Syntax: Each <clause> is of the form (<formals> <body>), where <formals> and9<body> have the same syntax as in a lambda expression.1011Semantics: A case-lambda expression evaluates to a procedure that accepts a12variable number of arguments and is lexically scoped in the same manner as a13procedure resulting from a lambda expression. When the procedure is called, the14first <clause> for which the arguments agree with <formals> is selected, where15agreement is specified as for the <formals> of a lambda expression. The16variables of <formals> are bound to fresh locations, the values of the17arguments are stored in those locations, the <body> is evaluated in the18extended environment, and the results of <body> are returned as the results of19the procedure call.2021It is an error for the arguments not to agree with the <formals> of any22<clause>.2324 (define range25 (case-lambda26 ((e) (range 0 e))27 ((b e) (do ((r '() (cons e r))28 (e (- e 1) (- e 1)))29 ((< e b) r)))))3031 (range 3) ==> (0 1 2)32 (range 3 5) ==> (3 4)3334---35Previous: [[Module (scheme base)]]3637Next: [[Module (scheme char))]]