From h.wickham at gmail.com  Thu Mar 28 19:40:03 2013
From: h.wickham at gmail.com (Hadley Wickham)
Date: Thu, 28 Mar 2013 13:40:03 -0500
Subject: [Rd] Ref classes initFields has incorrect environment?
Message-ID: <CABdHhvFOcTbX0YnQ8Uiz6C_QdWX_hu9kuA7gD8XgDLg+voEzrQ@mail.gmail.com>

As suggested by the following code:

A <- setRefClass("A", fields = list(x = "logical"),
  methods = list(initialize = function(...) {
    x <<- FALSE
    initFields(...)
}))
A$new()
# Works as expected

quote <- as.character
A$new()
# Error in function (value)  :
#  invalid replacement for field ?x?, should be from class ?logical?
or a subclass (was class ?character?)

I get the same error in:
* R version 2.15.2 (2012-10-26)
* R version 2.15.3 (2013-03-01)
* R Under development (unstable) (2013-03-28 r62432)

Hadley

-- 
Chief Scientist, RStudio
http://had.co.nz/



[Rd] Ref classes initFields has incorrect environment?
Hadley Wickham