Language Levels: Example

Consider a beginning student who is accustomed to infix syntax for function application: `f (x)`. This student may accidentally slip into this notation while programming in Scheme, for example, in a `cond` clause:
    (define (length l)
      (cond
        [empty? (l) 0]
        [else (+ 1 (length (rest l)))]))
This definition is syntactically legal in conventional Scheme, and a traditional implementation would signal an error only when the function is invoked. Because the beginner doesn't know about first-class functions, the error message is incomprehensible. DrScheme restricts the syntax of to a simple first-order language. By restricting the language, DrScheme can detect and flag beginner mistakes such as the one above. In this example it also highlights the offending clause, suggesting a natural revision to the beginner.