From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?SmFuIFN5bsOhxI1law==?= Newsgroups: gmane.lisp.guile.devel Subject: Re: (list-head lst k) with k longer than (length lst) Date: Wed, 18 Nov 2015 09:07:03 +0100 Message-ID: References: <20151117134425.60061f76@bother.homenet> <87io5071vr.fsf@netris.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1447834034 26543 80.91.229.3 (18 Nov 2015 08:07:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Nov 2015 08:07:14 +0000 (UTC) Cc: guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Nov 18 09:07:13 2015 Return-path: Envelope-to: guile-devel@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 1Zyxlp-0001HM-0W for guile-devel@m.gmane.org; Wed, 18 Nov 2015 09:07:13 +0100 Original-Received: from localhost ([::1]:34214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyxlj-0006Zy-Fz for guile-devel@m.gmane.org; Wed, 18 Nov 2015 03:07:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyxlg-0006Zq-SF for guile-devel@gnu.org; Wed, 18 Nov 2015 03:07:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zyxlf-00027c-Tf for guile-devel@gnu.org; Wed, 18 Nov 2015 03:07:04 -0500 Original-Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]:38448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zyxlf-00027T-NI for guile-devel@gnu.org; Wed, 18 Nov 2015 03:07:03 -0500 Original-Received: by wmec201 with SMTP id c201so61039328wme.1 for ; Wed, 18 Nov 2015 00:07:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=NRF3qnvHX39+ceMvhCcgwLOb+nx6Hkc4ZMNV4LAFzIw=; b=MoKPImHnnHXzwiaGiv19NSRpQEA/L4T0nom0Iu7RjheRLHnOk7kRK6Rzy4TPDD0sui eSlPjWnbPjywv1eKDA+uOxdnkRGgVBFgnu+R3nlBvV1k0MG0GItE87Zl/nLNrvCFLjjM aZtPCBDyTE8m7cCIQrHfAMQuLZGKMa+bMovUBpJN/Z5eLI/P7+/hHOWh6kgR2SYCREIm 9u8Mi9325Mk+ttm7G7PGLLtKIT99zqqhejkJK1r27Vsx5urT8EeJw6GY5qpZwRc+WRZg mmde+8S//O6gfc30imrr92X4D+a2zb4+udQFILmI6PJ/D2L1GX6afgbhLzk0f/dezd7+ bKNA== X-Received: by 10.28.213.12 with SMTP id m12mr2445512wmg.26.1447834023055; Wed, 18 Nov 2015 00:07:03 -0800 (PST) Original-Received: by 10.27.155.66 with HTTP; Wed, 18 Nov 2015 00:07:03 -0800 (PST) In-Reply-To: <87io5071vr.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c09::235 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:18035 Archived-At: On Tue, Nov 17, 2015 at 10:27 PM, Mark H Weaver wrote: > Chris Vine writes: > >> On Tue, 17 Nov 2015 11:53:05 +0100 >> Jan Syn=C3=A1=C4=8Dek wrote: >>> Hello, >>> >>> I'm getting: >>> >>> scheme@(guile-user)> (list-head '(1 2 3) 5) >>> ERROR: In procedure list-head: >>> ERROR: In procedure list-head: Wrong type argument in position 1 >>> (expecting pair): () >>> >>> This looks pretty much like a bug to me. Shouldn't list-head return >>> the entire list when the 'k' is bigger than its length? If that is not >>> the case, at least the error is really confusing. I'm using Guile >>> 2.0.11. >> >> The error message is confusing, but I guess the behaviour of list-head >> mirrors R5RS list-tail: instead of mandating the return of an empty >> list, R5RS states that "It is an error if list has fewer than k >> elements". > > Exactly right, but I agree that the error message is confusing. > > Unless otherwise specified, Scheme and Guile tend to be strict in cases > like this. For example, if a procedure is documented to "Copy the first > K elements from LST", and says nothing about what happens for lists with > fewer than K elements, you should assume that it's an error. > > Mark Thank you for the explanation. --=20 Jan Syn=C3=A1=C4=8Dek