From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.bugs Subject: bug#9776: case-lambda should accept zero clauses Date: Sun, 08 Jan 2012 04:45:45 +0000 Message-ID: <87ehvals3q.fsf@Kagami.home> References: <87ty77c4ab.fsf@weinholt.se> <87fwftu7lt.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1325998348 29364 80.91.229.12 (8 Jan 2012 04:52:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jan 2012 04:52:28 +0000 (UTC) Cc: 9776@debbugs.gnu.org, =?UTF-8?Q?G=C3=B6ran?= Weinholt To: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Jan 08 05:52:24 2012 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rjkk0-0000Wd-Ha for guile-bugs@m.gmane.org; Sun, 08 Jan 2012 05:52:20 +0100 Original-Received: from localhost ([::1]:57267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rjkjz-00068N-46 for guile-bugs@m.gmane.org; Sat, 07 Jan 2012 23:52:19 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:51310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rjkjs-00067M-VH for bug-guile@gnu.org; Sat, 07 Jan 2012 23:52:17 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rjkjd-00027X-2Y for bug-guile@gnu.org; Sat, 07 Jan 2012 23:52:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rjkjc-00027I-Tk for bug-guile@gnu.org; Sat, 07 Jan 2012 23:51:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Rjkji-0004IH-G7 for bug-guile@gnu.org; Sat, 07 Jan 2012 23:52:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ian Price Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 08 Jan 2012 04:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 9776 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 9776-submit@debbugs.gnu.org id=B9776.132599829816474 (code B ref 9776); Sun, 08 Jan 2012 04:52:02 +0000 Original-Received: (at 9776) by debbugs.gnu.org; 8 Jan 2012 04:51:38 +0000 Original-Received: from localhost ([127.0.0.1]:49337 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RjkjJ-0004He-VD for submit@debbugs.gnu.org; Sat, 07 Jan 2012 23:51:38 -0500 Original-Received: from mail-wi0-f172.google.com ([209.85.212.172]:43117) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1RjkjH-0004HQ-0e for 9776@debbugs.gnu.org; Sat, 07 Jan 2012 23:51:35 -0500 Original-Received: by wibhj6 with SMTP id hj6so2174672wib.3 for <9776@debbugs.gnu.org>; Sat, 07 Jan 2012 20:51:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=jiTuLcy2OTrV9lGsRrFnZpmEUu1yGH41w4u3XCU/038=; b=vd0qa0sK1UlvlCVVwUCDZ2fMqYA/yZY840R/mEugNNBvHvmiQ+hjNVONIgQSY5Uesp 956VC11Nf5UcAJA2I6Mnty/u4o5MyhgEHwoHms4XAUJzBIuG7xm3hhHb0W3SH+lxAFbk SS4i8PtUq2lEAlLAeHWkioEokcVEuETVtV1SY= Original-Received: by 10.180.88.169 with SMTP id bh9mr5835448wib.20.1325998283093; Sat, 07 Jan 2012 20:51:23 -0800 (PST) Original-Received: from Kagami.home (host86-171-77-216.range86-171.btcentralplus.com. [86.171.77.216]) by mx.google.com with ESMTPS id g26sm47871075wbo.16.2012.01.07.20.51.21 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 07 Jan 2012 20:51:22 -0800 (PST) In-Reply-To: <87fwftu7lt.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Thu, 05 Jan 2012 23:06:54 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:6024 Archived-At: ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi G=C3=B6ran, > > Sorry for the delay. > > G=C3=B6ran Weinholt skribis: > >> the case-lambda form is specified in r6rs-lib as accepting any number of >> clauses, including zero. So this should not give an error: > > My interpretation of the =E2=80=98case-lambda=E2=80=99 implementation on = p. 15 of > r6rs-lib.pdf is that =E2=80=98case-lambda-help=E2=80=99 raises an asserti= on violation > when =E2=80=98case-lambda=E2=80=99 is called with zero clauses. The case-lambda-help macro is expanded from within (lambda args (let ((n (length args))) (case-lambda-help args n (fmls b1 b2 ...) ...))) So, the full expansion is (lambda args (let ((n (length args))) (assertion-violation #f "unexpected number of arguments"))) and thus a procedure that always returns an assertion violation. > > The text itself doesn=E2=80=99t explicitly mention that zero clauses are > supported. I would disagree with this. Even without looking at the implementation, you see the specification of case-lambda as (case-lambda ...) The traditional meaning of ..., as seen in syntax-rules, and elsewhere in the r6rs, is 0 or more. Therefore a (case-lambda) form seems allowed to me. Oh, and an existence proof for good measure :) scheme@(guile=E2=88=92user)> (import (rnrs)) scheme@(guile=E2=88=92user)> (define-syntax case-lambda (syntax-rules () ((_ (fmls b1 b2 ...)) (lambda fmls b1 b2 ...)) ((_ (fmls b1 b2 ...) ...) (lambda args (let ((n (length args))) (case-lambda-help args n (fmls b1 b2 ...) ...)))))) scheme@(guile=E2=88=92user)> (define-syntax case-lambda-help (syntax-rules () ((_ args n) (assertion-violation #f "unexpected number of argume= nts")) ((_ args n ((x ...) b1 b2 ...) more ...) (if (=3D n (length =E2=80=99(x ...))) (apply (lambda (x ...) b1 b2 ...) args) (case-lambda-help args n more ...))) ((_ args n ((x1 x2 ... . r) b1 b2 ...) more ...) (if (>=3D n (length =E2=80=99(x1 x2 ...))) (apply (lambda (x1 x2 ... . r) b1 b2 ...) args) (case-lambda-help args n more ...))) ((_ args n (r b1 b2 ...) more ...) (apply (lambda r b1 b2 ...) args)))) scheme@(guile=E2=88=92user)> (case-lambda) $22 =3D #:734:0 args> scheme@(guile=E2=88=92user)> ($22) ERROR: ERROR: R6RS exception: 1. &assertion 2. &message: "unexpected number of arguments" 3. &irritants: () Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. scheme@(guile=E2=88=92user) [1]> ,q scheme@(guile=E2=88=92user)>=20 --=20 Ian Price "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled"