Skip to content
Prev 164426 / 398503 Next

R and Scheme

Peter Dalgaard wrote:
and what does the form of the syntax tree have to do with
lisp-likeness?  in java, c, etc., the string "1 + 2 + 3" would be parsed
into a tree that has the same shape as in the case of r:  a '+' in the
root, '1' in one branch, and in the other branch a tree with a '+' as
the root and '2' and '3' in the branches. 
"The point is that the general _form_ of the parse tree is the same." --
does it make java or c resemble lisp?
the point is, it's not a problem of the binary-ness of the particular
function `+`.  it's that an expression where the same operator is used
infix more than once in a row is parsed and evaluated as a nested
sequence of calls, not as a single call with multiple arguments:

`%+%` = function(a, b, c=0) { print (c(a,b,c)); a+b+c }
1 %+% 2 %+% 3
`%+%`(1,2,3)


vQ