POV-Ray : Newsgroups : povray.off-topic : C++ templates to get Java-style interfaces... Server Time
11 Oct 2024 13:15:14 EDT (-0400)
  C++ templates to get Java-style interfaces... (Message 6 to 15 of 15)  
<<< Previous 5 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: C++ templates to get Java-style interfaces...
Date: 21 Oct 2007 06:50:02
Message: <471b2ed1@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> (I'll also note there's a bunch of benefits to doing it the way Java 
> does that C++ templates can't support, too, having to do with strong 
> typing and dynamic loading and all that sort of stuff that C++ doesn't 
> do. But that's off topic.)

  I don't understand what stops you from writing "interfaces" in C++.
Just create a class with no member variables and with all the member
functions purely virtual, and there you are. (Why you would explicitly
avoid member variables and non-purely virtual functions is beyond my
grasp, but it is possible.)

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: C++ templates to get Java-style interfaces...
Date: 21 Oct 2007 11:38:25
Message: <471b7271@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> (I'll also note there's a bunch of benefits to doing it the way Java 
>> does that C++ templates can't support, too, having to do with strong 
>> typing and dynamic loading and all that sort of stuff that C++ doesn't 
>> do. But that's off topic.)
> 
>   I don't understand what stops you from writing "interfaces" in C++.

Nothing. It just doesn't give you the same benefits that doing it with 
Java does, due to the nature of the compilation process and object code 
storage formats.

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

From: Darren New
Subject: Re: C++ templates to get Java-style interfaces...
Date: 21 Oct 2007 11:41:26
Message: <471b7326$1@news.povray.org>
Warp wrote:
> (Why you would explicitly
> avoid member variables and non-purely virtual functions is beyond my
> grasp, but it is possible.)

Oh, and to clarify: By doing so, you get the things like strongly-typed 
dynamic loading that are difficult to do if you put code or allocation 
of data space in the interface.  I.e., because it lets you do the things 
that you can't do in C++.

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

From: Chambers
Subject: Re: C++ templates to get Java-style interfaces...
Date: 21 Oct 2007 18:35:00
Message: <web.471bd3c782fdd046fbb646420@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> http://permalink.gmane.org/gmane.comp.lib.boost.devel/166593

Actually, this looks really useful.  Not for the example posted, of course,
but in general :)


Post a reply to this message

From: Warp
Subject: Re: C++ templates to get Java-style interfaces...
Date: 21 Oct 2007 19:53:54
Message: <471be691@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> It just doesn't give you the same benefits that doing it with 
> Java does, due to the nature of the compilation process and object code 
> storage formats.

  What benefits are those?

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: C++ templates to get Java-style interfaces...
Date: 22 Oct 2007 00:10:31
Message: <471c22b7@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> It just doesn't give you the same benefits that doing it with 
>> Java does, due to the nature of the compilation process and object code 
>> storage formats.
> 
>   What benefits are those?

Strongly typed separate compilation units, and strongly typed dynamic 
loading, for two.

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

From: Warp
Subject: Re: C++ templates to get Java-style interfaces...
Date: 22 Oct 2007 05:39:58
Message: <471c6fee@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
> > Darren New <dne### [at] sanrrcom> wrote:
> >> It just doesn't give you the same benefits that doing it with 
> >> Java does, due to the nature of the compilation process and object code 
> >> storage formats.
> > 
> >   What benefits are those?

> Strongly typed separate compilation units, and strongly typed dynamic 
> loading, for two.

  I don't understand what that means.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: C++ templates to get Java-style interfaces...
Date: 22 Oct 2007 10:32:20
Message: <471cb474$1@news.povray.org>
Warp wrote:
> Darren New <dne### [at] sanrrcom> wrote:
>> Warp wrote:
>>> Darren New <dne### [at] sanrrcom> wrote:
>>>> It just doesn't give you the same benefits that doing it with 
>>>> Java does, due to the nature of the compilation process and object code 
>>>> storage formats.
>>>   What benefits are those?
> 
>> Strongly typed separate compilation units, and strongly typed dynamic 
>> loading, for two.
> 
>   I don't understand what that means.

Sure. Give me the .o file that corresponds to your template. (And before 
you explain that isn't how templates work, yes, I know. That's the point.)

Then compile three different C++ classes that have + and * and a fourth 
that doesn't into DLL files, and let me pass them into *my* template 
that requires + and * and make sure all four give me a well-defined result.

You *could* do that with code and data-allocation included, but it would 
be a lot more difficult.

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

From: Warp
Subject: Re: C++ templates to get Java-style interfaces...
Date: 22 Oct 2007 10:35:06
Message: <471cb519@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
> > Darren New <dne### [at] sanrrcom> wrote:
> >> Warp wrote:
> >>> Darren New <dne### [at] sanrrcom> wrote:
> >>>> It just doesn't give you the same benefits that doing it with 
> >>>> Java does, due to the nature of the compilation process and object code 
> >>>> storage formats.
> >>>   What benefits are those?
> > 
> >> Strongly typed separate compilation units, and strongly typed dynamic 
> >> loading, for two.
> > 
> >   I don't understand what that means.

> Sure. Give me the .o file that corresponds to your template. (And before 
> you explain that isn't how templates work, yes, I know. That's the point.)

  Uh, I was comparing Java interfaces with C++ classes with only pure
virtual functions and no member variables. That's exactly what I asked:
What is the difference between these two things? You responded with what
I quoted first above.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: C++ templates to get Java-style interfaces...
Date: 22 Oct 2007 10:51:20
Message: <471cb8e8$1@news.povray.org>
Warp wrote:
>   Uh, I was comparing Java interfaces with C++ classes with only pure
> virtual functions and no member variables. That's exactly what I asked:

Oh. I was referring to the benefits of
"""
I'll also note there's a bunch of benefits to doing it the way Java does 
that C++ templates can't support
"""

I hadn't realized you'd changed subjects.

> What is the difference between these two things? You responded with what
> I quoted first above.

Pretty much the same benefits. Separate compilation with strong typing, 
and dynamic loading with strong typing. Again, there's nothing really 
*stopping* a C++ compiler from doing strong typing for compilation and 
dynamic loading - it just isn't part of the language. (I.e., in the same 
way that nothing stops C++ from having threads, but it isn't part of the 
language you can count on.)

-- 
   Darren New / San Diego, CA, USA (PST)
     Remember the good old days, when we
     used to complain about cryptography
     being export-restricted?


Post a reply to this message

<<< Previous 5 Messages Goto Initial 10 Messages

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