From p.dalgaard@biostat.ku.dk  Fri Mar  3 13:26:14 2000
From: p.dalgaard@biostat.ku.dk (p.dalgaard@biostat.ku.dk)
Date: Fri, 3 Mar 2000 14:26:14 +0100 (MET)
Subject: [Rd] using function names as parameters (PR#469)
Message-ID: <200003031326.OAA20028@pubhealth.ku.dk>

Friedrich Leisch <Friedrich.Leisch@ci.tuwien.ac.at> writes:

> Hmm, I asked Torsten to mail the bug report ... I first thought along
> your lines and I would agree if I pass ``date'' as default, but we
> have ``date()'' as default argument which is the return value of the
> function, no?
> 
> IMO evaluating the default expression comes down to evaluating
> ``date <- date()'' which is perfectly legal ...
> 
> BTW, BB can do it:
> 
> S> foo <- function(date=date()) cat(date, "\n")
> S> foo()
> Fri Mar  3 09:49:20 MET 2000 
> Warning messages:
>   looking for function "date", ignored local non-function in: foo()

However,

> foo <- function(date=date) date             
> foo() 
Error in foo(): Recursive occurrence of default argument "date"
Dumped

So S-plus only works by assuming that the local variable is not a
function (*before* evaluating its default)! R is being cleaner and
more consistent..

-- 
   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-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] using function names as parameters (PR#469)
p.dalgaard@biostat.ku.dk