Re: [R] Scheme in R

About this list Date view Thread view Subject view Author view Attachment view

From: Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
Date: Fri 07 Dec 2001 - 09:29:19 EST


Message-id: <x27ks0rni8.fsf@blueberry.kubism.ku.dk>

Ed Kademan <kademan@phz.com> writes:

> The initial authors of R saidą, "...we implemented the language by
> first writing an interpreter for a Scheme subset and then
> progressively mutating it to resemble S." Further on in that article
> they elaborated that their strategy was to create a parser that would
> take expressions in S-like syntax and translate them to Scheme
> S-expressions.
>
> Does R still work that way? Can R be made to accept Scheme syntax
> directly? Can you build it in such a way that when you start it up
> you get a Scheme read-eval-print-loop instead of the S-like
> interactive environment? I ask simply because I happen to like
> Scheme/Lisp syntax. But it also occurred to me that---considering the
> ease with which you can implement specialized little languages in
> Scheme---such an interface might make it easier to experiment with
> things like extensions to model and graphics formulae.
>

Well, ... where do I start? The R (and to some extent also S)
internals are still very Lisp/Scheme like. The parser/evaluator hasn't
changed that much since the early versions of R. Perhaps the most
notable change is that a list object is not a dotted-pair list as in
Lisp anymore but a generic vector. (The pairlist object type still
exists, but is hardly ever used.) If you try picking apart an
expression using [[...]] you will see that almost everything maps to a
Lisp-like syntax, e.g.

 quote(x <- 2 + 3)

is essentially (<- x (+ 2 3)). Some slightly peculiar cases involve
for loops and expressions with non-local returns like break, and
return(). The evaluation model is somewhat non-Scheme because of the
lazy evaluation and substitute() aspects.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Thu 17 Jan 2002 - 11:10:10 EST