5 ms·
The comparison of Shen and Haskell caught my eye since Shen was mentioned in HN a few days ago, and I was looking into it. Since I've used Scheme and a port of
by jrapdx3 12y ago
The comparison of Shen and Haskell caught my eye since Shen was mentioned in HN a few days ago, and I was looking into it. Since I've used Scheme and a port of Shen runs under Chibi Scheme, I wondered what error would show up in Scheme. If I manage to get Shen working (under Chibi) it will be even more interesting to see what it does.
Translating, the original problem was:
(if (null? xs) (cdr xs) xs)
So:
(define (mytl xs) (if (null? xs) (cdr xs) xs))
And:
(mytl '())
Error: (cdr) bad argument type: ()
It appears (mytl) emits a type error in this instance.
This is obviously a run-time error, and without specific effort I don't think it would be known at compile-time in the Scheme implementations I'm familiar with.
Since the Scheme expression appears to embody the semantics of the original problem, I'm inclined to think it shows an underlying difference in the handling of the null list between CL and Scheme implementation I used.
If I'm completely wrong, and I can't rule out that possibility, I hope someone will point in the right direction.
- tel 12y agoOh! That's a runtime error... that changes everything.
- tizoc 12y agoIn Scheme asking for the car or cdr of an empty list is an error, and in Common Lisp it isn't (the result is the empty list itself). In Shen you have "hd" and "tl" which use whatever the platform provides (in Scheme it is going to fail, in Common Lisp it is going to return the empty list), and "head" and "tail" which work the same on all platforms (it is an error to pass an empty list to them, just like in Scheme). > If I manage to get Shen working (under Chibi) it will be even more interesting to see what it does. What problems are you experiencing? Please submit an issue on Github and I will look into it.