POV-Ray : Newsgroups : povray.off-topic : A question about Java generics (not a flame) : Re: A question about Java generics (not a flame) Server Time
7 Sep 2024 19:14:26 EDT (-0400)
  Re: A question about Java generics (not a flame)  
From: Warp
Date: 17 May 2008 04:36:31
Message: <482e990e@news.povray.org>
Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
> >   I understand this to also mean that the compiler is allowed to compile
> > an export template just once even if it's instantiated at several places,
> > using the context of one of those places.

> Only if all those places use the exact same template specialisation. Note  
> that this would require the compiler/linker to remember which translation  
> units use which exported templates, since the exported template must still  
> be recompiled if all of the relevant contexts change. Also note that the  
> linker would have to verify that at least one of the translation units  
> having an "unchanged" context actually gets linked in; if not, the  
> template would have to be recompiled.

  Sorry, I still don't understand this.

  I tried my foo-bar example making the bar() function a template which was
specialized in one of the compilation units but not the other, and at least
gcc still behave in the same way: When foo() was not inlined, only one
version of bar() was called: The specialized version was never called.

  From what you have written it sounds like the compiler would have to
always call the specialized bar() template if it is in the context of
the foo() instantiation, but at least gcc doesn't behave this way (and,
frankly, I don't know *how* it could behave that way without seriously
messing things up).

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.