[R] R and Scheme
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Wed Dec 10 23:02:08 CET 2008
Peter Dalgaard wrote:
> Johannes Huesing wrote:
>> Stavros Macrakis <macrakis at alum.mit.edu> [Wed, Dec 10, 2008 at
>> 04:59:25AM CET]:
>>> So I conclude that what is really meant by "R semantics are based on
>>> Scheme
>>> semantics" is "R has functions as first-class citizens and a correct
>>> implementation of lexical scope, including upwards funarg".
>>>
>>
>> One other thing reminiscient of Lisp is the infix notation (as in
>> "+"(1, 3)), which the authors have sprinkled with enough syntactic
>> sugar that the users
>> needn't be bothered with. To the benefit of ubiquity, I'd think.
>>
>
> That's prefix notation, infix is "1+3" (and postfix is "1,3,+" as in
> old HP calculators). But you're right that R has Lisp-like parse trees
> with a thin layer of syntactic sugar:
>
> Lisp writes function calls as (f x y) for f(x,y) and (+ 1 3) for 1+3.
> In R we have
>
> > e <- quote(f(x,y))
> > e[[1]];e[[2]]; e[[3]]
> f
> x
> y
> > e <- quote(1+3)
> > e[[1]];e[[2]]; e[[3]]
> `+`
> [1] 1
> [1] 3
>
the reminiscence is limited, though. the following won't do:
`+`(1,2,3)
and
quote(1+2+3)
is not a list of `+`, 1, 2, and 3.
vQ
More information about the R-help
mailing list