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:17:22 EDT (-0400)
  Re: A question about Java generics (not a flame)  
From: Warp
Date: 9 May 2008 20:49:51
Message: <4824f12e@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> For example, you have to parse and compile the 
> templates each time from source

  A compiler which supports export templates could conceivably have
precompiled templates for certain (although obviously not all) types,
such as for example for all basic types and STL classes. Thus it could
avoid having to compile them each time.

> and you get a new blob of code for each 
> type you instantiate a template with.

  If you are using the same code with two different types you are obviously
going to get two different pieces of code, no matter how you do it.
Templates just make it easier to avoid code repetition. (In other words,
if you want, for example, a vector of ints and a vector of doubles, you
don't need to write the vector code twice.)

  Templated data containers in C++ usually produce more memory-efficient
code than equivalent data containers using the pointer-to-base-Object
mechanism, which usually wastes a lot of memory. Thus any argument that
templates cause memory bloat is usually false. (Yes, there may be a few
situations where templated code causes more memory usage, but normally
it's the opposite.)

> Now, "crippled" is what I'd call the baroque C++ syntax.

  Syntax doesn't really matter all that much. It's how you use it.

-- 
                                                          - Warp


Post a reply to this message

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