Re: [Rd] unexpected behaviour when defining a function

2006-09-12 Thread Deepayan Sarkar
On 9/11/06, Prof Brian Ripley <[EMAIL PROTECTED]> wrote: > On Mon, 11 Sep 2006, Deepayan Sarkar wrote: > > > Hi, > > > > I know S manuals used to warn against using the same names for a > > variable and a function, but I have never seen that cause problems in > > R, so I usually don't pay much atte

Re: [Rd] unexpected behaviour when defining a function

2006-09-11 Thread Prof Brian Ripley
On Mon, 11 Sep 2006, Deepayan Sarkar wrote: > Hi, > > I know S manuals used to warn against using the same names for a > variable and a function, but I have never seen that cause problems in > R, so I usually don't pay much attention to it. But in this case you have a promise. (BTW, it can sti

Re: [Rd] unexpected behaviour when defining a function

2006-09-11 Thread Gabor Grothendieck
Sorry I forgot one of the dots. Here it is corrected: > bar <- function() 1 > foo <- function(bar. = bar()) { + bar. + } > foo() [1] 1 > foo(bar = bar) function() 1 On 9/12/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > You can't have x=x in an argument list. > > Try the following noti

Re: [Rd] unexpected behaviour when defining a function

2006-09-11 Thread Gabor Grothendieck
You can't have x=x in an argument list. Try the following noting that we put a dot at the end of bar: > bar <- function() 1 > foo <- function(bar. = bar()) { + bar + } > foo() function() 1 > foo(bar = bar) function() 1 On 9/11/06, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > Hi, > > I know

[Rd] unexpected behaviour when defining a function

2006-09-11 Thread Deepayan Sarkar
Hi, I know S manuals used to warn against using the same names for a variable and a function, but I have never seen that cause problems in R, so I usually don't pay much attention to it. Which is why the following behaviour came as a surprise: > bar <- function() 1 > foo <- function(bar = bar())