[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mon, 12 Nov 2012 14:54:45 +0100
((a b c #:key x) 3)
((a #:key x) 1)))
scheme@(guile-user)> (g 0 #:x 1)
$1 = 3
The manual says
> Also, for completeness. Guile defines case-lambda* as well, which is like
> case-lambda, except with lambda* clauses. A case-lambda* clause matches if
> the arguments fill the required arguments, but are not too many for the
> optional and/or rest arguments.
> Keyword arguments are possible with case-lambda*, but they do not contribute
> to the “matching” behavior. That is to say, case-lambda* matches only on
> required, optional, and rest arguments, and on the predicate; keyword
> arguments may be present but do not contribute to the “success” of a match.
> In fact a bad keyword argument list may cause an error to be raised.
I see that it gives 3 because ‘a b c’ matches ‘0 #:x 1’, so it's counting #:x
as an ‘argument’ by itself. This is not what I expected from the description
above. I think that the description should make clear that each item in the arg
list is counted as an argument for the purposes of matching.
Moreover I think this behavior makes case-lambda* fairly useless, or even
treacherous. I wonder what other people think.
- case-lambda* question,
Daniel Llorens <=