Re: [R] Evaluation of defaults in functions

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 29 Sep 2006 - 06:03:46 GMT

On Thu, 28 Sep 2006, hadley wickham wrote:

>>
>> And, to answer the specific question: Yes, R has lazy evaluation,
>> everywhere. Arguments are always evaluated if and when they are
>> needed.
>>
>
> But doesn't R has a rather limited force of lazy evaluation? - you
> have no control over it, apart from that arguments are evaluated
> lazily. This rather limited compared to other languages (no lazy
> lists etc)

I'd say that was a rather pure form.

However, Peter's statement is not quite true. R has several types of functions, and I think he is referring to closures, the functions written in R itself. The argument handling in the built-in functions (primitive and .Internal) is different, and they will often evaluate all the arguments whether needed or not.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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.
Received on Fri Sep 29 16:08:03 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 29 Sep 2006 - 15:30:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.