Re: [Re: [libxml++] UTF8 support]
- From: Jonathan Wakely <cow compsoc man ac uk>
- To: libxmlplusplus-general lists sourceforge net
- Subject: Re: [Re: [libxml++] UTF8 support]
- Date: Wed, 19 Mar 2003 16:03:29 +0000
On Wed, Mar 19, 2003 at 03:35:45PM +0100, Christophe de VIENNE wrote:
> About mixing the fully-templated lib and the 'normal' one :
I've been offline for a while so forgive me if I've missed anything...
> It seems (unless I misanderstood the thing) that the templates implementation
> don't have to be included in client code as long as the templated class
> instanciation is not done by the client code but by the lib.
Do you mean that the template classes would be explicitly instantiated
in the library? I'd been thinking about the same solution before I went
offline.
That would allow the member function definitions to be hidden from users,
but only if they want to use the templates with params that the library
has instantiated.
To use different template params a user would have to either:
* recompile the library so it explicitly instantiates the templates with
their choice of params. Maybe this could be done using clever configure
tricks, so when a new release of the lib is made the user configures
it to use their choice of string, and then just relink their apps to
the new lib.
or
* include the definitions into their code directly, which means users
must recompile their apps every time the definitions change.
> This way we wouldn't have to a heavy wrapping : only a few typedef, and
> provide functions to instanciate the different classes (which is already done
> for Node).
I'm not sure I understand what you mean here.
> I'd like comments/opinions on this. If I'm not clear don't hesite to ask more
> precisions.
I'm not sure how good compiler support is for this (I /think/ it's fine)
and am I right in thinking it delays some errors until link time, which
could be found at compile time (during the second stage of template
compilation) if the templates are instantiated automatically as the user
needs them?
One feature of explicit instantiation is that every member function is
instantiated. Usually a template's member functions are only instantiated
if they are used, which means errors can be introduced which testing
doesn't find unless every single function is called.
Explicit instantiation compiles every function so this is avoided (at
the cost of extra unused code in the object files)
I think this would be a good idea iff some autoconf trick can be done so
that the user specifies which explicit instantiations to include in the
library. Otherwise they still have to see the definitions and recompile
when the lib is updated.
A simple solution would be for the library to provide all the common
instantiations (glib::ustring, QString etc.) and conditionally compile
them according to options to configure (--with-ustring, --with-qstring).
To use the templates with new params would require compiling the
template def'ns yourself, or submitting a patch to the library to add a
new instantiation (and the new configure option to enable it).
jon
--
"What I tell you three times is true"
- The Hunting of the Snark
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]