Troy Robertson
2010-Oct-04 04:37 UTC
[Rd] Recursion error after upgrade to R_2.11.1 [Sec=Unclassified]
Hi all, After an upgrade from R_2.10.1 to R_2.11.1 I am now getting the following error: Error: evaluation nested too deeply: infinite recursion / options(expressions=)? This occurs in the initialize method of S4 classes where I was initialising attributes eg: .Object[['realtimeState']] <- list() I can avoid this new error by altering the code to do: .Object$realtimeState <- list() OR .Object@.xData$realtimeState <- list() My classes all extend .environment and store all changeable data as per above (in environment .xData slot) rather than in normal class slots because I am able to achieve much quicker execution times without all the copy-on-change cost that results from passing these objects containing large amounts of slot-based data. Can anyone provide a reason for the changes that have brought about the recursion issue? Is there a better way to achieve the pass-by-reference style objects I am after? Thanks Troy ___________________________________________________________________________ Australian Antarctic Division - Commonwealth of Australia IMPORTANT: This transmission is intended for the addressee only. If you are not the intended recipient, you are notified that use or dissemination of this communication is strictly prohibited by Commonwealth law. If you have received this transmission in error, please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and DELETE the message. Visit our web site at http://www.antarctica.gov.au/ ___________________________________________________________________________ [[alternative HTML version deleted]]
Troy Robertson
2010-Oct-04 23:25 UTC
[Rd] Recursion error after upgrade to R_2.11.1 [Sec=Unclassified]
Resending this in plain text, after realising the html text hadn't been posted (oops). Hi all, After an upgrade from R_2.10.1 to R_2.11.1 I am now getting the following error: Error: evaluation nested too deeply: infinite recursion / options(expressions=)? This occurs in the initialize method of S4 classes where I was initialising attributes eg: .Object[['realtimeState']] <- list() I can mostly avoid this new error by altering the code to do: .Object$realtimeState <- list() OR .Object at .xData$realtimeState <- list() But there are also times when I need to do .Object[realtimeState] <- list(NULL) in order to specifically set it to NULL (rather than have it removed) which I think is also causing me grief. My classes all extend .environment and store all non-static data as per above (in environment .xData slot) rather than in normal class slots because I am able to achieve much quicker execution times without all the copy-on-change cost that results from passing these objects containing large amounts of slot-based data. Can anyone provide a reason for the changes that have brought about the recursion issue? Is there a better way to achieve the pass-by-reference style objects I am after? Thanks Troy ___________________________________________________________________________ Australian Antarctic Division - Commonwealth of Australia IMPORTANT: This transmission is intended for the addressee only. If you are not the intended recipient, you are notified that use or dissemination of this communication is strictly prohibited by Commonwealth law. If you have received this transmission in error, please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and DELETE the message. Visit our web site at http://www.antarctica.gov.au/ ___________________________________________________________________________
Troy Robertson
2010-Oct-07 01:12 UTC
[Rd] Recursion error after upgrade to R_2.11.1 [Sec=Unclassified]
Hi all, After no replies to my previous message I thought I might show some code to demonstrate the change and again seek any explanation for the error now thrown by my code after upgrading from 2.10.1 to 2.11.1. Thanks Troy -------------------------------------------------------- setClass("PortableObject", representation(test1 = "character"), prototype( test1 = ""), contains = ".environment" ) setMethod("initialize", "PortableObject", function(.Object, ..., .xData=new.env(parent=emptyenv())) { .Object <- callNextMethod(.Object, ..., .xData=.xData) .Object at test1 <- "Foo" # Following line works under 2.10.1 but now throws # Error: evaluation nested too deeply: infinite recursion / options(expressions=)? #####.Object[["test2"]] <- "Bar" # The following does what I want though .Object$test3 <- "Baa" return(.Object) } ) e <- new("PortableObject") alterEGo <- function(o = "EPOCObject") { o at test1 <- "Boo" # Following line works under 2.10.1 but now throws # Error: evaluation nested too deeply: infinite recursion / options(expressions=)? ####o[["test2"]] <- "Who" # The following does what I want though o$test3 <- "Hoo" # NOTE: No return } alterEGo(e) e at test1 e$test2 e[["test3"]] e at .xData[["test3"]] ___________________________________________________________________________ Australian Antarctic Division - Commonwealth of Australia IMPORTANT: This transmission is intended for the addressee only. If you are not the intended recipient, you are notified that use or dissemination of this communication is strictly prohibited by Commonwealth law. If you have received this transmission in error, please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and DELETE the message. Visit our web site at http://www.antarctica.gov.au/ ___________________________________________________________________________