bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#17296: Uh, wrong?


From: Mark H Weaver
Subject: bug#17296: Uh, wrong?
Date: Wed, 04 Jun 2014 10:49:04 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

David Kastrup <address@hidden> writes:

> Mark H Weaver <address@hidden> writes:
>
>> David Kastrup <address@hidden> 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]