Thanks for the various thoughtful replies to my post "R and Scheme", where I
wondered what exactly people meant when they said that R semantics were
based on Scheme semantics.  R clearly has Scheme-like semantics for its
function objects, which are first-class objects and correctly implement
static/lexical scoping (or to use the old-fashioned terminology, support
upward funarg).  On the other hand, R differs from Scheme in many other
ways, in particular not supporting such important Scheme concepts such as
first-class continuations (and call/cc) and proper tail-recursion.

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".

As for the detailed comments:

About namespaces, I was not referring to partitioning the namespace for
packages etc, but the separate function and value namespaces of some Lisps
(including Common Lisp) as opposed to Scheme -- Lisp-1 and Lisp-2.

Call-by-need is a fairly standard way of referring to call-by-name where the
value is cached.  That is, function arguments are treated as argumentless
functions (a.k.a. thunks) which are called when their value is needed (that
is call-by-name), but the returned value is saved so that they are only
called once.  Of course, R's mechanism is a bit more than that, as the
argument's source code (quoted expression) is also available to the called
function via substitute.

dput/dget are not inverses in many cases.  To take some simple examples,
dput(1.0/3) when read back in is -3e-16 different from 1.0/3 (cf. Guy L.
Steele Jr. and Jon L. White, How to print floating-point numbers
accurately); dput(quote(c(1,2))) reads back the same as c(1,2); and
dput(quote(f(x))) isn't even readable with dget!  (And it is a security hole
if f *is* defined....)

As Tierney points out, callCC in R is not the same thing as call/cc in
Scheme. It supports catch/throw, but not coroutines etc.

My value-copy vs. reference-copy example was wrong; a[1] of course remains
1, not 999.

About multiple-value-returns, there are of course ways of simulating it, but
it is not part of the core semantics of the language.

Thanks again for the many interesting comments,

              -s

        [[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