[erlang-bugs] Lists module funnies

John Hughes john.hughes@REDACTED
Sat Nov 10 12:18:56 CET 2007


What's the next element in this sequence?

1> lists:seq(1,3).
[1,2,3]
2> lists:seq(1,2).
[1,2]
3> lists:seq(1,1).
[1]
4> lists:seq(1,0).

I expect [], but what I get is:

=ERROR REPORT==== 10-Nov-2007::12:11:21 ===
Error in process <0.30.0> with exit value:
{function_clause,[{lists,seq,[1,0]},{
erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}

** exited: {function_clause,[{lists,seq,[1,0]},
                             {erl_eval,do_apply,5},
                             {shell,exprs,6},
                             {shell,eval_loop,3}]} **

I've worked around this more times than I can remember, special-casing the
zero case to avoid calling seq, and I'll bet that many callers of seq have
to do the same thing. Any chance of changing this in the future? There can't
be much code that would break... code that only works today *because* seq
raises an exception.

John Hughes




More information about the erlang-bugs mailing list