2

Using DrRacket, on both linux and Mac OS, the following code gives this error

*: expects type <number> as 1st argument, given #<undefined>

but if I uncomment the (newline) at the beginning of the procedure definition, it works fine, yielding the expected value, 9.

#lang r5rs

(define (quadr x y)
        ;(newline)
        (define xx (* x x))
        (define yy (* y y))
        (define xxyy (* xx yy))
        (+ xx yy xxyy))

(display (quadr 1 2))
(newline)

Is this a bug in Racket's scheme interpreter, or is the language specified so that the nested invocations of (define ...) may happen out of order? If the latter is the case, where can I find the relevant bit of the language specification?

As an aside, I am very aware of the "let" construct and know that this is not the recommended way to define such a procedure. Still, I didn't expect this error.

4

1 に答える 1