[erlang-questions] lists:seq/[2,3] bug?

Kostis Sagonas <>
Fri Sep 19 17:30:46 CEST 2008

Richard A. O'Keefe wrote:
> On 19 Sep 2008, at 6:37 am, Nicolas Charpentier wrote:
>> Richard A. O'Keefe wrote:
>>>> I think that your proposition will break a lot of code.
>>> Why do you think that?  The correction I want ONLY affects
>>> cases where the current version blows up; whenever the
>>> current version returns any answer at all, mine returns the
>>> same one.
>> Hi,
>> With the current implementation, the process crashes if it calls  
>> With your proposition, the same process will continue to do things  
>> but using an empty sequence.
> ONLY in the case M = N - 1, and BECAUSE IT MAKES SENSE.

Despite all the shouting, I've yet to read a coherent argument why the 
case M = N - 1 is more special than e.g. the case M = N - 42.

[Please realize that similarly to "expect", the expression "makes sense" 
is also highly subjective.  I do not see why throwing an exception for 
M<N does not make sense.]

Haskell, where exceptions are problematic, at least is consistent in its 
behaviour. In Haskell the equivalent of lists:seq/2 defines a *total* 
function over the integers, not a function that returns [] in some 
special cases only. Disregarding for a moment that throwing exceptions 
in Erlang is OK, why would Erlang have a different behaviour ?

>> For me, this is a big difference and all running applications must  
>> be checked to ensure that they can handle empty sequence correctly.
> It is also the case right now that all existing code that uses seq
> should be checked to ensure that it DOESN'T expect empty results.
> I know what the manual says, but people find it easier to remember
> stuff that makes sense, and so it's entirely credible that other
> people than me would have test cases
> that fall down dead when N = 0 *but shouldn't*.

I repeat: If we were to change the behaviour of lists:seq/2 -- and so 
far I've not yet read something that convinced me we should -- how is 
the above different than e.g. lists:seq(8, 5) ?


More information about the erlang-questions mailing list