comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Treating an object as a structure
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Treating an object as a structure [message #65487 is a reply to message #65432] Fri, 06 March 2009 14:36 Go to previous messageGo to previous message
JDS is currently offline  JDS
Messages: 94
Registered: March 2009
Member
I use this technique a lot:

snapshot=create_struct(NAME=obj_class(self))

or simply

snapshot={MYCLASS}
struct_assign,self,snapshot

later apply snapshot:

struct_assign,snapshot,self

This allows me to make snapshots of object data for the purpose of
undoing changes, or examining how it was at a certain point in time.
Keep a pointer to a list of these, and you have multiple undo. Add a
text phrase when snapshotting ("Frobnoid change") and you can
advertise "Undo Forbnoid change" and so on.

The lack of garbage collection starts getting painful at this point
though (since older versions could refer to data newer versions have
deleted).

Remember that snapshots of heap pointers (at whatever level in the
heirarchy) are not immutable. If you want a deep copy, you can use
the save/restore trick, first calling the new HEAP_NOSAVE routine on
items you won't need a deep copy of. Or you can simply replicate
certain heap data by hand (new=ptr_new(*old)). This reminds me that
we're still lacking deep copy capability without hitting the disk.

JD
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: netCDF Read/Write Variable
Next Topic: Probably a Stupid Question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 00:32:54 PDT 2025

Total time taken to generate the page: 1.44057 seconds