GNU bug report logs -
#17296
[PATCH] SRFI-1 'length+' raises an error unless passed a proper or circular list
Previous Next
Reported by: Mark H Weaver <mhw <at> netris.org>
Date: Fri, 18 Apr 2014 19:29:02 UTC
Severity: normal
Tags: patch
Done: Mark H Weaver <mhw <at> netris.org>
Bug is archived. No further changes may be made.
Full log
Message #22 received at 17296 <at> debbugs.gnu.org (full text, mbox):
David Kastrup <dak <at> gnu.org> writes:
> Mark H Weaver <mhw <at> netris.org> writes:
>
>> David Kastrup <dak <at> gnu.org> writes:
>>> So the behavior for length+ on a dotted list is strictly unspecified.
>>> It is not even stated "it is an error".
>>
>> Actually, it is. At the end of the section that defines the "types"
>> such a "clist" and "flist", it states:
>>
>> It is an error to pass a circular or dotted list to a procedure not
>> defined to accept such an argument.
>>
>> While it is true that we are not required to signal an error, I'm wary
>> extending 'length+' in this way. It also effectively extends 'map' and
>> 'for-each' to support things like (map + '() 'foo), and thus potentially
>> affects many other procedures both inside and outside of Guile that use
>> 'map' and 'for-each'. Once we've done this, users are likely to grow
>> dependent on it and we can never go back.
>
> That is true for _any_ particular choice for unspecified behavior.
> _Including_ throwing an error as a means of checking input validity.
>
> You are proposing providing functions _not_ defined in srfi-1 at all for
> functionality that is clearly desirable even for implementing behavior
> required by some functions in srfi-1.
If we want things like (map + - * /) to signal an error, then we need a
'length+' that signals an error when passed - or * or /. In fact,
that's precisely what motivated me to make 'length+' more strict.
So, you and I are coming at this from different angles. I want a strict
'length+' to implement 'map' and 'for-each', and you want a lax one to
implement 'drop-right' et al. It seems to me that we need both.
The fact that the SRFI-1 reference implementation of 'length+' is lax
very nearly swayed me over to your position, but there's a problem:
Guile's 'length+' has (always?) returned #f for dotted lists. It would
be dangerous to silently change the behavior of this case from one
non-error to another non-error. Programs could start silently
misbehaving without any clue that anything went wrong.
Mark
This bug report was last modified 10 years and 244 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.