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

Re: Improper lists

This page is part of the web mail archives of SRFI 1 from before July 7th, 2015. The new archives for SRFI 1 contain all messages, not just those from before July 7th, 2015.

>    >    (let recur ((x x))
>    >      (if (pair? x) 
>    >          (cons (car x) (recur (cdr x)))
>    >          y))
>    But this borders on the absurd, because under this definition,
>       (append '(a b c . d) '(e f g)) => (a b c e f g)
>    that is, the d is silently dropped.  What kind of sense does that make?
> Plenty of sense -- the D isn't doing anything except terminating that
> list. Once you get used to thinking of D as an empty list, Lars, you're going
> to love it.

I agree with Lars et al.  An improper list is not a list!!!  If someone
wants to mix them, explicit conversions should be performed.  In the
early days Gambit's append (and other functions) silently treated
non-pairs as the empty list as in

       (append '(a b c . d) '(e f g)) => (a b c e f g)

but some people complained that this did not help them catch errors
early in their programs.  Now I have tightened up the type checks to
signal an error.