Topic: Shared Libraries and Template Instantia


Author: brewin@Eng.Sun.COM (Bob Brewin)
Date: 3 Aug 1994 16:25:19 GMT
Raw View
In article 94Aug3014943@deneb.cygnus.com, jason@cygnus.com (Jason Merrill) writes:
> >>>>> Andrew Werth <ajw1@cc.bellcore.com> writes:
>
> > How much of the class does this instantiate?  All member functions?
>
> Yes.
>
> > Does it instantiate the class into the current object module?
>
> Unspecified.  It may go into the current object module or into some
> repository structure or nowhere.
>
> > How do you get the object code into a library with complete closure so
> > that clients of the library won't re-instantiate code?
>
> Unspecified.  This is really a quality of implementation issue; all the WP
> says is that a template shall not be explicitly instantiated more than
> once, and no diagnostic is required for that rule -- D&E even encourages
> implementations to disregard it.  So the explicit instantiation syntax is
> little more than a hint to the compiler.
>
> Personally, I feel that the right way to implement explicit instantiation
> is for it to instantiate into the current object module, so that libraries
> can be made.  So that's the way g++ does it.  Other vendors may feel
> differently.
>
> Jason


I can't see why explicit instantiation should have to make any difference as to
where an instance should go... I think it's a separate issue.  Normally, I would
prefer to have my instantiation 'go somewhere' ( a repository, etc., ) so that I
don't end up re-instantiating unneccessarily (of course we *could* instantiate into
the current module and just note the fact that the instantiation 'lives' there...
unfortunately, there is no guarantee that on the final 'link' line, that module
will be included by our intrepid user).

- Bob -






Author: jason@cygnus.com (Jason Merrill)
Date: Fri, 5 Aug 1994 00:54:21 GMT
Raw View
>>>>> Bob Brewin <brewin@Eng.Sun.COM> writes:

> In article 94Aug3014943@deneb.cygnus.com, jason@cygnus.com (Jason Merrill) writes:
>> Personally, I feel that the right way to implement explicit instantiation
>> is for it to instantiate into the current object module, so that libraries
>> can be made.  So that's the way g++ does it.  Other vendors may feel
>> differently.

> I can't see why explicit instantiation should have to make any difference
> as to where an instance should go... I think it's a separate issue.
> Normally, I would prefer to have my instantiation 'go somewhere' ( a
> repository, etc., ) so that I don't end up re-instantiating
> unneccessarily (of course we *could* instantiate into the current module
> and just note the fact that the instantiation 'lives' there...
> unfortunately, there is no guarantee that on the final 'link' line, that
> module will be included by our intrepid user).

The way I see it, if a user puts an explicit instantiation in their code,
that means they want the template instantiated there; otherwise they could
just as well let the automatic mechanism deal with it.  If they decide not
to include that module in the link, well, then the automatic mechanism
should deal with it in any case.

Treating explicit instantiation this way allows users to avoid worrying
about the speed or complexity of the automatic mechanism by worrying about
exactly which instantiations they need instead.  Some people like to be
able to make that tradeoff.

Jason