Re: [boost] serializatation const change (was Re: Problem withserialization mersenne_twister with cvs)

----- Mensaje original ----- De: Jeff Garland <jeff@crystalclearsoftware.com> Fecha: Sábado, Mayo 28, 2005 8:06 pm Asunto: Re: [boost] serializatation const change (was Re: Problem withserialization mersenne_twister with cvs)
On Sat, 28 May 2005 10:05:15 -0700, Robert Ramey wrote [...]
I don't see this change as "breaking code" but rather detecting code that is very likely already broken.
So, as I said, its not that I'm unsympathetic to your point of view, I just don't think everyone is sympathetic to mine.
Well, I'd say that 'no one' is sympathetic to yours, yet ;-) I don't think that Vladimir, myself, or the others that have posted on this topic are convinced that this change is really going to prevent people from making the error you are concerned about.
For the record, not that I'm in love with the stricter const rules either, but I must confess that, when hit by them the first time, they actually uncovered a (potential) problem in my test code. So... I've been thinking about this issue, and my impression is that regular code won't be hit as much as one might think. Typically, serialization is used like this in a program: class my_class { // add serialziation capabilities }; void save(const my class&) { // some file-opening work prior to actual saving ... } void load(my_class&) { // some file-opening work prior to actual loading ... } A typical program will have a centralized point of usage of serialization, and the usual const-abiding rules won't collide with Boost.Serialization. Now, a test program like the ones we've been writing to check the serialization capabilities of our libs is more likely to follow this pattern: std::ofstream ofs(..); archive::text_oarchive oa(ofs); my_class_1 c1; ... my_class_n cn; ... oa<<c1; ... oa<<cn; std::ifstream ifs(..); archive::text_iarchive ia(ofs); my_class_1 cc1; ... my_class_n ccn; ... ia>>cc1; ... ia>>ccn; BOOST_CHECK(c1==cc1); ... BOOST_CHECK(cn==ccn); and here we *do* run into the const problem. The key difference is that, in the latter pattern of usage, we are creating local classes just to check whether they're properly archived and restored. In a real program, the serialization code is typically provided a class to archive from the outside, as serializating classes created on the fly doesn't make much sense after all. Get my point? So, to sum it up, although I think stricter const rules won't prevent as many problems as desired, I think most users won't notice anyway. We lib testers belong to a different flock. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

JOAQUIN LOPEZ MU?Z wrote:
For the record, not that I'm in love with the stricter const rules either, but I must confess that, when hit by them the first time, they actually uncovered a (potential) problem in my test code. So...
I've been thinking about this issue, and my impression is that regular code won't be hit as much as one might think.
All will be fine in simple cases, where all you do is recursively serialize members. To give a data point, in one of my recent projects one out of the nine classes does not serialize its members directly. This is the unversioned case. Once you add versioning, you almost always have to serialize a temporary object to take care of the previous versions, but I'm not sure whether this is an issue if one only supports versioned loading (and not saving) with Boost.Serialization.

Peter Dimov wrote:
JOAQUIN LOPEZ MU?Z wrote:
For the record, not that I'm in love with the stricter const rules either, but I must confess that, when hit by them the first time, they actually uncovered a (potential) problem in my test code. So...
I've been thinking about this issue, and my impression is that regular code won't be hit as much as one might think.
All will be fine in simple cases, where all you do is recursively serialize members. To give a data point, in one of my recent projects one out of the nine classes does not serialize its members directly. This is the unversioned case. Once you add versioning, you almost always have to serialize a temporary object to take care of the previous versions,
I'm not sure I'd agree with that. But
but I'm not sure whether this is an issue if one only supports versioned loading (and not saving) with Boost.Serialization.
I'm not even sure what versioned saving would mean. If it means something and its supported by the library, its would be totally unintentional on my part. This issue doesn't arise during load - unless one is loading into a const member. This case would trap anyway and require a cast - as I believe it should. Robert Ramey

Robert Ramey wrote:
I'm not even sure what versioned saving would mean. If it means something and its supported by the library, its would be totally unintentional on my part.
Versioned saving means that one supports saving into a prior version; for example, saving an 1.32 archive with Serialization 1.33. Judging by the comment // note, version is always the latest when saving in "Splitting serialize into save/load" it seems that this is not supported and hence, not an issue.
participants (3)
-
JOAQUIN LOPEZ MU?Z
-
Peter Dimov
-
Robert Ramey