[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Objects, File Names, and the Save command.



I am exploring a very promising use of the save/restore commands in
conjuction with objects.  Given some complex object which contains a
host of different types of data (with pointers, etc.), as part of a
class method, one adds:

save, self, FILENAME=fname 

to register on disk an accurate snapshot of the object.  To restore,
later, use:

restore,pname,RESTORED_OBJECTS=obj,/RELAXED_STRUCTURE_ASSIGNMENT

and the object is in obj, but also brought back as the local variable
*self*.  I'm not sure the relaxed structure assignment flag works for
objects, but I don't see why it wouldn't.  So this can be used in two
ways ... 

1. To allow an object to replace *itself* with another, perhaps older
copy (or even an altogether different type of object -- but the utility
of self-transmogrifying objects is not yet apparent to me).  This works
because the implicit self variable is passed by reference (as it has to
be).  This will lead to at least one unreferenced heap variable unless
garbage collection steps are taken, i.e. by saying:
	oldself=self
	restore, pname,/RELAXED_STRUCTURE
	obj_destroy,oldself

2.  To allow a program module to load up an object on the fly, through
the obj variable in the above statement (only one should be loaded if
only one was saved).

This is all very convenient but leads to the strange situation of a
loaded object in memory which exists there *before* any of the class
methods, and/or the __define procedure for that object class are
compiled.  Therefore, the usual paradigm of putting all class methods in
the __define procedure file before this procedure (suggested by RSI
itself in the manual) fails.  How can the method be found if the
__define doesn't have to be compiled and isn't in it's own file?  I
would like to come up with a solution which doesn't involve a separate
class__method.pro file for each method.  Any ideas?

Thanks,

JD
-- 
 J.D. Smith                             |*|      WORK: (607) 255-5842    
 Cornell University Dept. of Astronomy  |*|            (607) 255-6263
 304 Space Sciences Bldg.               |*|       FAX: (607) 255-5875 
 Ithaca, NY 14853                       |*|