One correction: On 10/22/10 10:55 AM, John Chambers wrote: .....
As a suggestion, it would be nice if the accessors() method could be used to create just "getters" or just "setters" for particular fields, although I realise this can be worked around by removing the unwanted methods afterwards.In other words, read-only fields. There is a facility for that implemented already, but it didn't yet make it into the documentation, and it could use some more testing. The generator object has a $lock() method that inserts a write-once type of method for one or more fields. Example: > fg <- setRefClass("foo", list(bar = "numeric", flag = "character"), + methods = list( + addToBar = function(incr) { + b = bar + incr + bar <<- b + b + } + )) > fg$lock("bar") > ff = new("foo", bar = 1.5) > ff$bar <- 2 Error in function (value) : Field "bar" is read-only
Actually it is documented in the section on generator objects. But since I also didn't see it, maybe it needs an example. ;-)
John ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
