[Peter Dalgaard] >[François Pinard] >>I meant that R might have implemented a Scheme engine [...] with >>a surface language [...] which is purposely not Scheme, but could have >>been. [...] one could dare dreaming that the Scheme engine in R be >>"completed", and Scheme offered as an alternate extension language. >>[...] there are excellent Scheme compilers. [...]
>Well, depending on what you want, this is either trivial or >impossible... I'm more leaning on the "impossible" side :-). >The internal storage of R is still pretty much equivalent to scheme. R needs a few supplementary data types, and it motivated the R authors into re-implementing their own Scheme engine instead of relying on an existing implementation of a Scheme system. > > r2scheme <- function(e) [...] Nice exercise! :-) >a parser that parses a similar language to R internal format is not >a very hard exercise (some care needed in places). However, replacing >the front-end is not going to make anything faster, Of course. The idea is nothing more than to please people starving to use Scheme instead of S as a surface language, here and there in scripts. I merely thought that if the gap is small enough (so to not require an extraordinary effort), it would be worth the leap. One immediate difficulty to foresee is the name clashes between R and RnRS. There might also be missing things in R (like continuations, say). To make anything faster, and this is a totally different idea, one might consider replacing the back-end, not the front-end. Writing good optimizing Scheme compilers is quite an undertaking, and if one only considers type inference (as a subproblem), this still is an active research area. The Scheme engine in R was written as to quickly get a working S (non-obstant lexical scoping and some library issues). My ramble was about switching this quick base of R to some solid Scheme implementation, than to re-address separately compiling issues for R. >and the evaluation engine in R does a couple of tricks which are not >done in Scheme, notably lazy evaluation, Promises? Aren't they already part of Scheme? The main difference I saw is their systematic use in R argument passing. All aspects of mere argument passing would require a lot of thought. As you wrote, variable scope is another difficulty. Offering a compatible C API, and library interface in general, might be a frightening but necessary challenge. It's all more of a dream than a thought, actually... :-) >Look up the writings of Luke Tierney on the matter to learn more. Thanks for this interesting reference. -- François Pinard http://pinard.progiciels-bpi.ca ______________________________________________ R-help@stat.math.ethz.ch 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.