From: Mark H Weaver <mhw@netris.org>
To: Chris Vine <chris@cvine.freeserve.co.uk>
Cc: guile-devel@gnu.org
Subject: Re: (list-head lst k) with k longer than (length lst)
Date: Tue, 17 Nov 2015 16:27:20 -0500 [thread overview]
Message-ID: <87io5071vr.fsf@netris.org> (raw)
In-Reply-To: <20151117134425.60061f76@bother.homenet> (Chris Vine's message of "Tue, 17 Nov 2015 13:44:25 +0000")
Chris Vine <chris@cvine.freeserve.co.uk> writes:
> On Tue, 17 Nov 2015 11:53:05 +0100
> Jan Synáček <jan.synacek@gmail.com> 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
next prev parent reply other threads:[~2015-11-17 21:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-17 10:53 (list-head lst k) with k longer than (length lst) Jan Synáček
2015-11-17 13:44 ` Chris Vine
2015-11-17 21:27 ` Mark H Weaver [this message]
2015-11-18 8:07 ` Jan Synáček
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87io5071vr.fsf@netris.org \
--to=mhw@netris.org \
--cc=chris@cvine.freeserve.co.uk \
--cc=guile-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).