I do not understand the following behavior between these two Scheme programs:
Program 1:
(define a
(begin
(display "hmmm")
(newline)
lambda))
This program, run using scheme test.ss
, gives me a syntax error at the lambda
line without printing out the string "hmm"
.
Program 2:
(define lambda 5)
(define a (+ 1 2 lambda))
The end result here is that a
is equal to 8
.
The behavior in the first program is the behavior I expect in both programs. What confuses me is why the second program does not fail with a syntax error. Clearly I am redefining lambda
, but I would think that this would fail with a syntax error before that code could actually be run. It seems to me that to know that this is not a syntax error you would need to actually run the program, but if this was the behavior then I would expect the first program to display the string before it errors out.
In short, why does the first program result in a syntax error while the second program does not?