Boost logo

Boost :

From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2007-03-16 10:02:04


On 3/16/07, Janek Kozicki <janek_listy_at_[hidden]> wrote:
> Robert Ramey said: (by the date of Thu, 15 Mar 2007 18:56:25 -0800)
>
> > Zach Laine wrote:
> > > I did something stupid with my serialization code. I blithely changed
> > > the names of several polymorphic classes everywhere they appeared in
> > > the code, since they had moved out of a class into that class's
> > > namespace (e.g. SomeNS::View::Primitive became SomeNS::Primitive).
> > > Several months later, I discovered that I could no longer read old
> > > binary archives, because I was using Boost.Serialization's
> > > BOOST_CLASS_EXPORT() macro, and this macro was now registering the
> > > Primtive type with the name-string "Primitive", instead of
> > > "View::Primitive", which is how it was saved in the oldest archives.
> >
> > Ouch.
>
> IMHO this is the best example demonstrating that sometimes using a
> class name as a GUID is not the best idea. If Zach from the very
> beginning used a custom string (different that the class name) as a
> GUID, this thing would have never happened. Am I right?

This was my thought as well. In fact, I'm going to switch all our
BOOST_CLASS_EXPORT(T) macros to BOOST_CLASS_EXPORT_GUID(T, "[T's
canonical name]") macros, and leave a giant note for others to do the
same ("Here there be dragons", etc.). In light of this problem, I
would say that while use of BOOST_CLASS_EXPORT() is convenient, it is
ultimately a maintenance burden.

Zach Laine


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk