4 ms·
One of the more frustrating aspects of Scheme, to me, is that most implementations layer a defacto strong type system on a weakly-typed base (something CL does
by chandler 19y ago
One of the more frustrating aspects of Scheme, to me, is that most
implementations layer a defacto strong type system on a weakly-typed base
(something CL does not suffer from, to a certain extent). "What does this
mean," you ask? Here we go!
(define (dumb-fun s)
(let ((front (substring s 0 3))
(back (substring s (- (string-length s 4))
(sub1 (string-length s)))))
(or (string-ci=? front "was")
(string-ci=? back "good")
(string-ci=? s "Yesterday"))))
Notice how, even though we didn't declare "s" to be a string when binding it, we
end up declaring its type in every single function call involving it.
Basically, most Scheme implementations end up with some kind of bizarre
inverse-type system, where programmers perform all of the work (extensive type declarations) and receive none of the
reward (compile-type type checking).
(This is all an artifact of how the rXrs's have been traditionally
written--lacking standard support for generic functions or type-introspection, they've essentially set the precedent by "typing" the functions
provided in the standard. For example, and straight from r5rs, we have:
length
string-length
vector-length
<=
char<=?
string<=?
Is it any surprise implementations end up with functions like 'bytes-length',
'hash-table-length', etc?).
It seems that pg is vaguely cognizant of this deficiency by overloading the
common operators; however, unlike CL (or even Haskell, for that matter), Arc
doesn't yet provide a way of extending the functions beyond the predefined
types.