From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Llorens Newsgroups: gmane.lisp.guile.user Subject: Re: case-lambda* question Date: Mon, 19 Nov 2012 10:43:51 +0100 Message-ID: References: <7A088671-9922-4ECF-A5C5-841AEFDBCA80@bluewin.ch> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1353318247 3383 80.91.229.3 (19 Nov 2012 09:44:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Nov 2012 09:44:07 +0000 (UTC) Cc: guile-user@gnu.org To: Daniel Hartwig Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Nov 19 10:44:18 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TaNtp-000860-4x for guile-user@m.gmane.org; Mon, 19 Nov 2012 10:44:17 +0100 Original-Received: from localhost ([::1]:40781 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaNte-0007pB-Gn for guile-user@m.gmane.org; Mon, 19 Nov 2012 04:44:06 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaNtX-0007om-RR for guile-user@gnu.org; Mon, 19 Nov 2012 04:44:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TaNtU-0003Bf-Nq for guile-user@gnu.org; Mon, 19 Nov 2012 04:43:59 -0500 Original-Received: from zhbdzmsp-smta15.bluewin.ch ([195.186.99.132]:59429) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TaNtU-0003Ab-H6 for guile-user@gnu.org; Mon, 19 Nov 2012 04:43:56 -0500 Original-Received: from [195.186.227.131] ([195.186.227.131:40761] helo=zhhdzmsp-smta14.bluewin.ch) by zhbdzmsp-smta15.bluewin.ch (envelope-from ) (ecelerity 2.2.3.47 r(39824M)) with ESMTP id 0B/AD-21834-85FF9A05; Mon, 19 Nov 2012 09:43:52 +0000 Original-Received: from [10.23.3.29] (128.179.67.121) by zhhdzmsp-smta14.bluewin.ch (8.5.142) (authenticated as dll@bluewin.ch) id 50A62199003B505D; Mon, 19 Nov 2012 09:43:52 +0000 In-Reply-To: X-Mailer: Apple Mail (2.1085) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.186.99.132 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9705 Archived-At: On Nov 15, 2012, at 02:22, Daniel Hartwig wrote: > On 14 November 2012 18:20, Daniel Llorens = wrote: >>> When the doc. states keyword arguments do not contribute to the >>> success of a match, it refers only to keyword arguments in the >>> case-lambda clause, not at the call site. This makes sense, = otherwise >>> it would inhibit writing functions that detect keywords internally >>> from their rest arguments. >>=20 >> Do you mean something like this? >>=20 >> (define* (f a #:key x) x) >> (define (g . args) (apply f args)) >> (g 0) -> #f >> (g 0 #:x #t) -> #t >>=20 >> i.e. g must accept being called with 3 'arguments' so that it can = forward the keyword args. >=20 > I was thinking of: >=20 > (define f > (case-lambda* > ((a . rest) > (if (memq #:x rest) =85 >=20 > where #:x is picked up from inside rest. >=20 > Based on the other error, I'd say that any case-lambda* with keyword > arguments is matched with a rest argument instead, i.e. =93a #:key x=94 = is > treated as =93a . rest=94. Ok, I think I see how=20 (define f (case-lambda* ((x #:optional y) 1) ((x #:key y) 2) ((x y #:key z) 3))) (f #:y 2) works. x is #:y and y is 2. However, this should go to (x y #:key z) and it doesn't: (f 1 2 #:z 3) -> Odd length of keyword argument list while given (define g (case-lambda* ((a #:key x) 1) ((a b c #:key x) 3))) this should match (a b c #:key x) and it doesn't.=20 (g 1 2 3) - > Invalid keyword Or maybe we should say that (g 1 2 3) shouldn't match (a #:key x)? = Either way, I'll file these as a bug. Thanks, Daniel