[R] Formal definitions of R-language.

Thomas Lumley tlumley at u.washington.edu
Mon Jul 21 04:35:32 CEST 2003


On Mon, 21 Jul 2003, Richard A. O'Keefe wrote:

> Murad Nayal <mn216 at columbia.edu> wrote:
> 	recursion, as far as I know, is inefficient in
> 	S/R. which tend to discourage purely functional programming.
>
> It's not so much that _recursion_ is slow, as that function calling
> is slow (whether recursive or not).  A large part of the reason is
> that the S function calling convention was designed to favour
> human ease-of-use much more than ease of compilation.
>

The biggest problem with recursion in comparison to languages like Scheme
and compiled LISPs may be that R can't eliminate any of the recursions.
Even tail-recursion elimination (which is compulsory in Scheme) isn't
possible without changing the semantics of the language, because functions
like sys.frame() give access to all the frames that would be optimised out
of existence.

In my experience recursive functions run reasonably well in R until they
hit the stack limit.

	-thomas




More information about the R-help mailing list