Define_Type overhead
Spire_Jeff
Posts: 1,917
Does anyone know how much overhead is involved with creating structures? The reason I ask is that I currently use 4 different structures to house a bunch of configuration information. I am finding that I need to occasionally add items to the structure. The problem arises in that I am currently using the variable_to_string function to store the configuration to disk and I don't think I can retrieve the data if I change the structure. (I cannot use variable_to_xml because of flaws in the function)
The way I am trying to solve this is by using a version file that indicates what version the data was saved as. I then use that to read the data into a stack_var of the correct version type and then populate the current structure accordingly. Right now, I only have 2 or 3 versions of each structure, so I doubt that the extra structure definitions will cause problems, but I wanted to make sure. I am also thinking about the future and trying to decide how many previous versions I will let the program automatically convert.
I can always write a separate program that simply goes through and updates the files, but I kind of like the ability to restore backup files on the fly as long as they are within a couple versions of the current.
Jeff
The way I am trying to solve this is by using a version file that indicates what version the data was saved as. I then use that to read the data into a stack_var of the correct version type and then populate the current structure accordingly. Right now, I only have 2 or 3 versions of each structure, so I doubt that the extra structure definitions will cause problems, but I wanted to make sure. I am also thinking about the future and trying to decide how many previous versions I will let the program automatically convert.
I can always write a separate program that simply goes through and updates the files, but I kind of like the ability to restore backup files on the fly as long as they are within a couple versions of the current.
Jeff
0
Comments
As for your other issue, I usually find it best to break the structures into a more generic form. My preference is to feed the data out into a CVS file, then read it back in when the module loads. Then you could put your version number right in the first CVS record, and interpret it accordingly as it's read ... when you write the data out again, it can automatically update the version accordingly.
I would not use a binary data store for the reason you mentioned. Simple text is the most flexible if you come up with your own scheme, depending on the data. I have abandoned structures except in limited cases and use only arrays now. Until they change things so that structures can be passed to modules and functions I will use arrays.
Paul