Skip to content

save/load hooks

2 messages · Tim Keitt, Brian Ripley

#
I'd like to suggest a small feature be added to R.  It would be nice if
"load" and "save" had function hooks for object initialization and
finalization, e.g.,

	load.hook <- function(x) UseMethod("load.hook")
	save.hook <- function(x) UseMethod("save.hook")

These would then be called on each object saved or loaded.  The default
method would do nothing.   This would allow saved objects to
reinitialize their state when loaded.

Cheers,
Tim
#
On Fri, 21 Jul 2000, Timothy H. Keitt wrote:

            
R objects contain their complete state as far as R is concerned.  Could you
give us an example of why you want this?  I guess you must have some
non-standard objects in mind, in which case it seems wasteful to do this
for all R objects in a workspace.

Another potential problem on loading is ordering: how do you ensure that
what you want to do is already available?  The workspace is loaded before
any profiles, so only a minimal set of functions is available, excludng any
packages bar base.  And the error handling at that stage is I think
incomplete, given that tey() does not work in profiles.