Script interpreter bug?
Posted: Sat Jun 27, 2009 9:51 am
I was trying to write some useful code when I found a problem. Some testing revealed a pattern:
(test zero 1) -> 0
debug displays: [lambda expression] 1
(test add 1) -> 0
debug displays: add 1
(add 1) -> 1
The red expression should evaluate to 1 but evaluates to 0 like function 'zero' is still operator. This happens whenever a lambda expression uses a parameter as an operator--like. The lambda expression evaluates correctly on its first application, but on subsequent applications it still uses the operator's first value and not the parameter's actual value.
Is the interpreter supposed to do that?
Code: Select all
(setq test (lambda (a b)
(block Nil
(dbgOutput a)
(dbgOutput b)
(a b))))
(setq zero (lambda (a) 0))
debug displays: [lambda expression] 1
(test add 1) -> 0
debug displays: add 1
(add 1) -> 1
The red expression should evaluate to 1 but evaluates to 0 like function 'zero' is still operator. This happens whenever a lambda expression uses a parameter as an operator--like
Code: Select all
(lambda (parameter ...)
(parameter operand ...))
Is the interpreter supposed to do that?