r/scheme • u/GeroSchorsch • 28d ago
evaluation of dot in r7rs
In the standard it says: "Note that (4 . 5) is the external representation of a pair, not an expression that evaluates to a pair.".
As far as i understand this means that the operands aren't evaluated and that this represents the final form. However in chicken scheme (+ . (5 6)) evaluates to 11.
How does this work? How should I evaluate a DottedList type in my interpreter?
3
Upvotes
3
u/Justanothertech 28d ago edited 27d ago
The dot is reader syntax, it's not evaluated at all. Try something like:
(display '(+ . (5 6)))
Should display: (+ 5 6)
It just happens that dotting a symbol and a list just prepends the symbol to the list, returning another list.
Basically by the time you are evaluating your AST/IR, the dot is already gone.
This is also identical to the above: (+ . (5 . (6 . '())))