2011/1/19  <[email protected]>:
> [...]
> Jeha, i know. A list is a pair, but a pair is not a list. Therefore a list
> should be a subclass of pair. (Ok, for '() we have <null>).
> [...]

Hello,

that is wrong, and you even give the reason why it's wrong yourself: A
list is either a pair or the empty list. Hence the singleton type of
the empty list and the type of all pairs are subtypes of the type of
lists, but not vice versa.

If the type of lists was a subtype of the type of pairs, every list
would have to be a pair, but that is not true since the empty list is
not a pair. This is one of the subtle differences between Scheme and
Common Lisp, where the car and cdr operations are also applicable to
the empty list (resulting in the empty list again).

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to