From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98023 invoked by alias); 19 Apr 2017 15:22:55 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 98006 invoked by uid 89); 19 Apr 2017 15:22:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=chicken, H*r:sk:kawa@so, Chicken, kawa X-HELO: homiemail-a19.g.dreamhost.com Received: from sub3.mail.dreamhost.com (HELO homiemail-a19.g.dreamhost.com) (69.163.253.7) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Apr 2017 15:22:53 +0000 Received: from homiemail-a19.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a19.g.dreamhost.com (Postfix) with ESMTP id 70A16604084 for ; Wed, 19 Apr 2017 08:22:53 -0700 (PDT) Received: from vereq.eip10.org (cpe-74-75-122-130.maine.res.rr.com [74.75.122.130]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: chaw@eip10.org) by homiemail-a19.g.dreamhost.com (Postfix) with ESMTPSA id 51F2E604076 for ; Wed, 19 Apr 2017 08:22:53 -0700 (PDT) Received: from chaw by vereq.eip10.org with local (Exim 4.84_2) (envelope-from ) id 1d0rRU-0007SS-Dp for kawa@sourceware.org; Wed, 19 Apr 2017 11:22:52 -0400 To: kawa Subject: Using #!optional, #!rest, and #!key together From: "Sudarshan S Chawathe" Reply-To: "Sudarshan S Chawathe" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28670.1492615372.1@vereq.eip10.org> Date: Wed, 19 Apr 2017 15:22:00 -0000 Message-ID: <28671.1492615372@vereq.eip10.org> X-IsSubscribed: yes X-SW-Source: 2017-q2/txt/msg00028.txt.bz2 Some background: I'd like to define a procedure that accepts a few keyword-arguments as well as a variable number of non-keyword arguments (both required and optional). So, I'm looking at using #!optional, #!rest, and #!key together but am confused by the specification. Which brings me to my main, somewhat vague, question: 1. What is a good way to achieve the above (in Kawa)? My more specific questions follow. 2. When a lambda uses #!key, my reading of the specification seems to require an even number of actual arguments following the required+optional actual arguments in a corresponding invocation, even if there is a #!rest. Is that really the case? 3. To be even more specific, given (define (test-args a b #!optional c d #!rest e #!key (f 'vf) (g 'vg)) (list a b c d e f g)) is it true that the first of the following is OK but the second is an error? (test-args 1 2 3 4 5 6 f: 7 g: 8) (test-args 1 2 3 4 5 f: 6 g: 7) Kawa doesn't flag an error (which is fine, I understand), but binds f and g to 7 and 8 in the first case, and to their default values vf and vg in the second case, so it does seem to treat them quite differently. My confusion is probably not specific to Kawa, as the relevant text in the manual is probably essentially from the DSSSL spec (based on similar text in other manuals). However, Chicken and Bigloo (just the ones I looked at) seem to have implemented extensions that work around the above issues and I'm trying to figure out a suitable strategy using Kawa. I'm guessing others have encountered similar situations and have some good solutions, which I would love to hear. Regards, -chaw