[R] Lisp-like primitives in R

Gabor Grothendieck ggrothendieck at gmail.com
Sat Sep 8 15:19:26 CEST 2007


On 9/8/07, Peter Dalgaard <p.dalgaard at biostat.ku.dk> wrote:
> François Pinard wrote:
> > [Roland Rau]
> >
> >> [François Pinard]
> >>
> >
> >
> >>> I wonder what happened, for R to hide the underlying Scheme so fully,
> >>> at least at the level of the surface language (despite there are
> >>> hints).
> >>>
> >
> >
> >> "To further foster portability, we chose to write R in ANSI C...."
> >>
> >
> > Yes, of course.  Scheme is also (often) implemented in C.  I meant that
> > R might have implemented a Scheme engine (or part of a Scheme engine,
> > extended with appropriate data types) with a surface language (nearly
> > the S language) which is purposely not Scheme, but could have been.
> >
> > If the gap is not extreme, one could dare dreaming that the Scheme
> > engine in R be "completed", and Scheme offered as an alternate extension
> > language.  If you allow me to continue dreaming awake -- "they" told me
> > "they" will let me free as long as I do not get dangerous! :-) -- part
> > of the interest lies in the fact there are excellent Scheme compilers.
> > If we could only find or devise some kind of marriage between a mature
> > Scheme and R, so to speed up the non-vectorisable parts of R scripts...
> >
> >
> Well, depending on what you want, this is either trivial or
> impossible... The internal storage of R is still pretty much equivalent
> to scheme. E.g. try this:
>
>  > r2scheme <- function(e) if (!is.recursive(e))
>      deparse(e) else c("(", unlist(lapply(as.list(e), r2scheme)), ")")
>  > paste(r2scheme(quote(for(i in 1:4)print(i))), collapse=" ")
> [1] "( for i ( : 1 4 ) ( print i ) )"
>

Also see showTree in codetools:

> library(codetools)
> showTree(quote(for(i in 1:4)print(i)))
(for i (: 1 4) (print i))



More information about the R-help mailing list