From hb at stat.berkeley.edu  Thu Jun  4 03:35:42 2009
From: hb at stat.berkeley.edu (Henrik Bengtsson)
Date: Wed, 3 Jun 2009 18:35:42 -0700
Subject: [Rd] function(x,
	dim=dim(x)) { str(dim) } => recursive default 	argument reference
In-Reply-To: <59d7961d0906031707v22dbf065t8d96d927fd7c1d31@mail.gmail.com>
References: <59d7961d0906031707v22dbf065t8d96d927fd7c1d31@mail.gmail.com>
Message-ID: <59d7961d0906031835t78375743nd184f5e81447e233@mail.gmail.com>

My bad:

http://tolstoy.newcastle.edu.au/R/e2/help/07/09/25387.html

/Henrik

On Wed, Jun 3, 2009 at 5:07 PM, Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
> Is the following a bug?
>
> Rterm -vanilla
>
>> foo <- function(x, dim=dim(x)) { str(dim) }
>> foo(1:2)
> Error in str(dim) :
> ?promise already under evaluation: recursive default argument
> reference or earlier problems?
>> foo(x=1:2)
> Error in str(dim) :
> ?promise already under evaluation: recursive default argument
> reference or earlier problems?
>
> But, this works:
>
>> foo <- function(x, dim2=dim(x)) { str(dim2) }
>> foo(1:2)
> ?NULL
>
>> foo <- function(x, dim=base::dim(x)) { str(dim) }
>> foo(1:2)
> ?NULL
>
>
>> sessionInfo()
> R version 2.9.0 Patched (2009-05-28 r48680)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MON
> ETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base
>
> /Henrik
>



[Rd] function(x, dim=dim(x)) { str(dim) } => recursive default argument reference
Henrik Bengtsson