I have two constructs that I expected to be functionally the same, but they are not and I can't figure out why.
Using define
(define (x2 . b)
(display b)
(newline))
(x2 3 4 5) => (3 4 5)
Using lambda
((lambda (. b)
(display b)
(newline))
3 4 5) => Error: invalid use of `.'
In the R5RS, both definitions and lambdas accept . To make them behave identically I could construct the lambda like this:
((lambda b
(display b)
(newline))
3 4 5) => (3 4 5)
That is one of the valid constructs listed in report's definition of formal parameters. But if I attempt to use it with define, it results in an argument number mismatch error.
(define (x2 b)
(display b)
(newline))
(x2 3 4 5) => Error: bad argument count
I thought (define (x y) y)
was just syntactic sugar for (define x (lambda (y) y))
. It seems like that is true only in most cases. Can anyone explain the rationale for the different behavior?