[Rd] Reference Classes: removing methods -> implications for objects/instances of that class

From: Janko Thyson <janko.thyson_at_ku-eichstaett.de>
Date: Tue, 23 Nov 2010 22:11:47 +0100


ink1">Dear list,

just to make sure that I understand 'unregistering' methods for S4 reference classes correctly:

If I registered a method and want to 'unregister' (i.e. remove) this method again, objects/instance created of the respective class still feature the removed method until I do an explicit reassign ('my.instance <- getRefClass("Classname")$new()'), right?

setRefClass("Shab", fields=list(a="numeric"))
# Register method

getRefClass("Shab")$methods(list(aSquare=function() a^2)) getRefClass("Shab")$methods()

# Create instance

shab <- getRefClass("Shab")$new()
shab$a <- 10

# Use method

shab$aSquare()

# Remove method

getRefClass("Shab")$methods(list(aSquare=NULL))

getRefClass("Shab")$methods() 	# Gone.
shab$aSquare() 				# Still possible

shab    <- getRefClass("Shab")$new()
shab$aSquare() 				# Not possible anymore

Is it also possible to remove a method so that all instances do not feature the respective method anymore without having to resort to an explicit reassign? Or is this technically not possible or not a desired feature?

TIA,
Janko

########## SYSTEM INFO ##########
Windows XP SP3
R 2.12.0 (patched as of 2010-11-22)
Eclipse 3.6.1 (Helios)
StatET 0.9.x

###############################

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 23 Nov 2010 - 21:15:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 27 Nov 2010 - 11:10:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive