I've read in many places that R semantics are based on Scheme semantics.  As
a long-time Lisp user and implementor, I've tried to make this more precise,
and this is what I've found so far.  I've excluded trivial things that
aren't basic semantic issues: support for arbitrary-precision integers;
subscripting; general style; etc. I would appreciate corrections or
additions from more experienced users of R -- I'm sure that some of the
points below simply reflect my ignorance.

==Similarities to Scheme==

R has first-class function closures. (i.e. correctly supports upward and
downward funarg).

R has a single namespace for functions and variables (Lisp-1).

==Important dissimilarities to Scheme (as opposed to other Lisps)==

R is not properly tail-recursive.

R does not have continuations or call-with-current-continuation or other
mechanisms for implementing coroutines, general iterators, and the like.

R supports keyword arguments.

==Similarities to Lisp and other dynamic languages, including Scheme==

R is runtime-typed and garbage-collected.

R supports nested read-eval-print loops for debugging etc.

R expressions are represented as user-manipulable data structures.

==Dissimilarities to all (modern) Lisps, including Scheme==

R has call-by-need, not call-by-object-value.

R does not have macros.

R objects are values, not pointers, so a<-1:10; b<-a; b[1]<-999; a[1] =>
999.  Similarly, functions cannot modify the contents of their arguments.

There is no equivalent to set-car!/rplaca (not even pairlists and
expressions).  For example, r<-pairlist(1,2); r[[1]]<-r does not create a
circular list. And in general there doesn't seem to be substructure sharing
at the semantic level (though there may be in the implementation).

R does not have multiple value return in the Lisp sense.

R assignment creates a new local variable on first assignment, dynamically.
So static analysis is not enough to determine variable reference (R is not
referentially transparent). Example: ff <- function(a){if (a) x<-1; x} ;
x<-99; ff(T) -> 1; ff(F) -> 99.

In R, most data types (including numeric vectors) do not have a standard
external representation which can be read back in without evaluation.

R coerces logicals to numbers and numbers to strings. Lisps are stricter
about automatic type conversion -- except that false a.k.a. NIL == () in
Lisps other than Scheme.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to