From ripley at stats.ox.ac.uk  Wed Dec 21 10:48:48 2005
From: ripley at stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Wed, 21 Dec 2005 10:48:48 +0100 (CET)
Subject: [Rd] NextMethod causes R 2.2.0 to crash (PR#8416)
Message-ID: <20051221094848.0CB2219A78@slim.kubism.ku.dk>

Bill,

This is a 2.2.0 Windows problem, solved in 2.2.1.  What happened was that 
someone trying to be helpful increased the evaluation nesting limit in 
2.1.0, and Windows has a small C stack (2Mb) which can easily be exceeded.
I now get

> julian(m)

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

as I should.  The nesting limit has been reduced and the C stack size 
increased.

It is legitimate to call NextMethod in a default method, but it is all too 
easy to get loops.  In your case you want the Date method, not the next 
method (which since there is only one class will be the default).

I would advise Windows users of 2.2.0 to

1) update
2) if that is not possible, set options(expressions=1000).

Brian

On Wed, 21 Dec 2005 Bill.Venables at csiro.au wrote:

> I found writing the following default method the for the generic
> function "julian" causes R to crash.
>
>
> julian.default <- function(x, ...) {
>        x <- as.Date(x)
>        NextMethod("julian", x, ...)
> }
>
> Here is a test example
>
>> m <- as.Date("1972-09-27") + 0:10
>> m
> [1] "1972-09-27" "1972-09-28" "1972-09-29" "1972-09-30" "1972-10-01"
> "1972-10-02" "1972-10-03"
> [8] "1972-10-04" "1972-10-05" "1972-10-06" "1972-10-07"
>> class(m)
> [1] "Date"
>> julian(m)
> [1] 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010
> attr(,"origin")
> [1] "1970-01-01"
>
>> m <- as.character(m)
>> class(m)
> [1] "character"
>
>> julian(m)
>
> < R crashes>
>
> --please do not edit the information below--
>
> Version:
> platform = i386-pc-mingw32
> arch = i386
> os = mingw32
> system = i386, mingw32
> status =
> major = 2
> minor = 2.0
> year = 2005
> month = 10
> day = 06
> svn rev = 35749
> language = R
>
>
>
> Bill Venables,
> CMIS, CSIRO Laboratories,
> PO Box 120, Cleveland, Qld. 4163
> AUSTRALIA
> Office Phone (email preferred): +61 7 3826 7251
> Fax (if absolutely necessary):    +61 7 3826 7304
> Mobile (rarely used):                +61 4 1963 4642
> Home Phone:                          +61 7 3286 7700
> mailto:Bill.Venables at csiro.au
> http://www.cmis.csiro.au/bill.venables/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] NextMethod causes R 2.2.0 to crash (PR#8416)
ripley@stats.ox.ac.uk