unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* case-lambda* question
@ 2012-11-12 13:54 Daniel Llorens
  2012-11-13  2:46 ` Daniel Hartwig
  2013-01-14 10:39 ` Andy Wingo
  0 siblings, 2 replies; 13+ messages in thread
From: Daniel Llorens @ 2012-11-12 13:54 UTC (permalink / raw)
  To: guile-user


(define f
	(case-lambda*
		((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.

Regards,

	Daniel

 


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-01-15 12:01 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12 13:54 case-lambda* question Daniel Llorens
2012-11-13  2:46 ` Daniel Hartwig
2012-11-14  0:55   ` Germán A. Arias
2012-11-14 10:20   ` Daniel Llorens
2012-11-14 17:53     ` Germán A. Arias
2012-11-15  1:01       ` Germán A. Arias
2013-01-14  9:41         ` Andy Wingo
2012-11-15  1:22     ` Daniel Hartwig
2012-11-19  9:43       ` Daniel Llorens
2013-01-14  9:39     ` Andy Wingo
2013-01-14 10:39 ` Andy Wingo
2013-01-14 12:22   ` Ludovic Courtès
2013-01-15 12:01   ` Daniel Llorens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).