POV-Ray : Newsgroups : povray.off-topic : A question about Java generics (not a flame) Server Time
8 Sep 2024 03:18:15 EDT (-0400)
  A question about Java generics (not a flame) (Message 61 to 63 of 63)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Fredrik Eriksson
Subject: Re: A question about Java generics (not a flame)
Date: 17 May 2008 05:52:26
Message: <op.ubalpng87bxctx@e6600.bredbandsbolaget.se>
On Sat, 17 May 2008 10:36:31 +0200, Warp <war### [at] tagpovrayorg> wrote:
>   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.

Your foo-bar example is ill-formed. The compiler can do whatever it wants.



>   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).

It is commonly called "two-phase lookup" (though it is not named as such  
in the standard) and is explained in section 14.6 [temp.res] of the  
standard. Section 14.6.4 [temp.dep.res] deals specifically with dependent  
name resolution.

Compiler writers have been rather slow in implementing two-phase lookup  
properly, almost as slow as with implementing 'export'.



-- 
FE


Post a reply to this message

From: Warp
Subject: Re: A question about Java generics (not a flame)
Date: 17 May 2008 07:41:18
Message: <482ec45e@news.povray.org>
Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
> On Sat, 17 May 2008 10:36:31 +0200, Warp <war### [at] tagpovrayorg> wrote:
> >   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.

> Your foo-bar example is ill-formed. The compiler can do whatever it wants.

  How is it different from your example, which you gave earlier? Also you
had a template function calling another template function, and the latter
being specialized in the context of instantiating the former. That's exactly
what I did.

-- 
                                                          - Warp


Post a reply to this message

From: Fredrik Eriksson
Subject: Re: A question about Java generics (not a flame)
Date: 17 May 2008 07:56:24
Message: <op.ubarf9o57bxctx@e6600.bredbandsbolaget.se>
On Sat, 17 May 2008 13:41:18 +0200, Warp <war### [at] tagpovrayorg> wrote:
> Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
>> Your foo-bar example is ill-formed. The compiler can do whatever it  
>> wants.
>
>   How is it different from your example, which you gave earlier? Also you
> had a template function calling another template function, and the latter
> being specialized in the context of instantiating the former. That's  
> exactly what I did.


The difference is that you are instantiating 'foo<int>' in more than one  
place. When you do that, the instantiations must have the same meaning or  
the program is ill-formed. In my example 'f<int>' is only instantiated  
once. That example was intented only to demonstrate why an exported  
template must be recompiled when code that uses it is changed.



-- 
FE


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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