[S] Can't formal argument name == actual name?

Terry Elrod (Terry.Elrod@UAlberta.ca)
Mon, 15 Jun 1998 07:29:32 -0600


> # Perhaps I'm losing my mind, but I swear this has worked, and ought to
work...
> y <- 5
> y
[1] 5
> .f
function(y = y)
{
y
}
> .f()
Error in .f(): Recursive occurrence of default argument "y"
Dumped
> traceback()
Message: Error in .f(): Recursive occurrence of default argument "y"

5: .f()
4: eval(expr, local = F)
3: .Sapi.build.output(txt = ".f()\n", hints = c("SapiOutput",
"SapiErrorText", "SapiWarningText",
2: .C(NAME = "S_api_get_message",
1:
> # The problem disappears when the actual and formal names do not agree, of
course ...
> .f2
function(x = y)
{
x
}
> .f2()
[1] 5
> # The problem has nothing to do with returning an object named y ...
> .f3
function(y = y)
{
z <- y
z
}
> .f3()
Error in .f3(): Recursive occurrence of default argument "y"
Dumped
> # Using inspect shows that the problem arises in trying to obtain the
value of y from
> # within the frame.
>
> # I'm running S-Plus 4.5 rel. 1 under Windows 95.

Terry Elrod
------------------------------------------------------------------------
Terry Elrod; Assoc. Prof. of Marketing
3-23 Faculty of Business; Univ. of Alberta; Edmonton, AB; Canada T6G 2R6
phone: 403-492-5884; fax: 403-492-3325; email: Terry.Elrod@UAlberta.ca
------------------------------------------------------------------------

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news