Re: [libxml++] Re: [Libxmlplusplus-general] Node ownership



Murray Cumming wrote:

what is a private structure ?


You said "by inspecting the _impl". I assumed that you meant inspecting
by accessing the private structure.

well, unfortunately, this is C, and there is just no way to destinguish
private and public. So it all has to work by convention. Either the
'doc' member of the xmlNode struct is public, or it is not, in which
case there should be an accessor. There is no accessor, so I assume
it is public, i.e. meant to be used by application code (such as
libxml++).
But again, let me confirm this with DV.


Or just assume that you know what you are doing. The existence of an
is_owned_by_libxml() method wouldn't force you to use it.

Yes, but even then I'd prefer to be able to just throw
'invalid_argument' or something, instead of watching the application
crash.


As an application developer you may do that if you like.

no, I'm talking about libxml++ code. We shouldn't assume the user knows
what he is doing. We should make the API as intuitive and correct as
possible. The success of an API is not measured in terms of those
users who 'know what they are doing', but by its robustness, including
whether or not the semantics are clear. If they are not, people will
write buggy code with it. That's a failure for *our* project, not the
application.

But being able to use the delete operator would be very hacky, because
it implies a circular dependency that you'd need to break out explicitely:

Node::~Node()
{
  if (_impl)
  {
    _impl->private = 0; // make sure this destructor isn't called twice
    xmlFreeNode(_impl);
  }
}


Maybe. We deal with similar, but more complex, things successfully in
gtkmm. I don't think it's a problem.

Well, I call it bad design, sorry.

Stefan






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