Scheme is notorious for returning unintelligible error messages. For instance, I was working on an iteration and recursion lab this morning and I ran into this oddity and the code that caused it.
;Ill-formed special form: (define sum-range a b count)
(define sum-range a b count) ; no procedure code yet )
The error message mentions special form. If you’re learning Scheme, you should remember that
define is a special form. It’s special in that it does not use the applicative ordering method for evaluation, among other things I suspect. So, somehow, the special form for
define is incorrect. Any ideas? Can you spot the syntax error?
sum-range does not have a leading parenthesis? The procedure needs to be lead by a parenthesis so that it is its own expression (in terms of the special-formy-ness that is
define). In short, the code should have read like so:
(define (sum-range a b count) ; no procedure code yet )
It was really as easy as that.