[ESS] ess-developer mode and reference classes

Laurent Gatto laurent.gatto at gmail.com
Wed May 29 18:33:43 CEST 2013

Dear all,

I have a reference class defined like this

.Synapter <-
              fields = list(
                Version = "character",
                SynapterLog = "character",
              methods = list(
                initialize = function() {
              ## and many more

Using ess-developer mode, C-c C-p on that paragraph evals in the
appropriate package environment, and all is fine.

It happens however that more methods are defined later in the file

## more methods
                       moremethod1 = function() {
                       ## many methods
                       moremethodN = function() {

If I now C-c C-p these new methods or C-c C-l the complete file I
obtain the following error

Error in eval({ :
  error in evaluating the argument 'expr' in selecting a method for
function 'eval': Error in .Synapter$methods(list(searchGrid =
function(ppms, nsds, subset,  (from synapter-class.R#308) :
  the definition of class “Synapter” in package ‘synapter’ is locked,
methods may not be redefined

where 308 is the exact line where the second set of methods are
defined. Note that I do not explicitly lock any fields.
(If of interest, the complete code is available on

Reading through ?setRefClass, I found the following for $methods(...),
that suggests the above might not be totally unexpected:
"In particular, methods can not be redefined in a class in an attached
package with a namespace: The class method checks for a locked binding
of the class definition."

Hoping I have not missed anything obvious, is there a way to get
around this in ess-developer mode?

Thank you in advance.

Best wishes,


[ Laurent Gatto | slashhome.be ]

More information about the ESS-help mailing list