[Rd] E`<`<rrors in recursive default argument references
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon Mar 9 23:42:34 CET 2009
Stavros Macrakis wrote:
> On Mon, Mar 9, 2009 at 5:40 PM, Wacek Kusnierczyk
> <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> wrote:
>
>> Stavros Macrakis wrote:
>>
>>> Tested in: R version 2.8.1 (2008-12-22) / Windows
>>>
>
>
>> when i run these examples, the execution seems to get into an endless
>> loop with no error messages whatsoever. how much time does it take
>> before you get the error? (using r 2.8.0 and also the latest r-devel).
>>
>
> In 2.8.1/Windows (32 bit), they return immediately, though the
> stack-overflow case is about 13x slower.
>
>
>> system.time(for (i in 1:100) {trySilent((function(a=a)(a))())})
>>
> user system elapsed
> 0.67 0.00 0.67
>
this won't stop within a minute, running at 100% cpu, have to kill the
process.
>> system.time(for (i in 1:100) {trySilent((function(a=a)as.POSIXct(a))())})
>>
> user system elapsed
> 0.05 0.00 0.05
>
user system elapsed
0.064 0.000 0.067
> Are you running under 64 bits? How long does a vanilla infinite
> recursion take to fail on your machine? I get:
>
32 bits ubuntu 8.04
>
>> system.time(for (i in 1:100) trySilent({fff <- function()fff(); fff()}))
>>
> user system elapsed
> 0.27 0.00 0.26
>
user system elapsed
0.204 0.008 0.212
vQ
PS i'm looking into the sources; in src/main/eval.c:317 there is a check
for whether the promise has been seen:
if(PRSEEN(e))
it appears that when i evaluate
(function(a=a) -a)()
the check is not passed (the condition is false -- promise not seen).
seems like the evaluation goes into a loop before the promise is marked
as seen. (or i misunderstand the code, likely.)
vQ
More information about the R-devel
mailing list