POV-Ray : Newsgroups : povray.off-topic : Games programmers : Re: Games programmers Server Time
10 Oct 2024 17:19:40 EDT (-0400)
  Re: Games programmers  
From: Warp
Date: 12 Sep 2008 04:48:41
Message: <48ca2ce8@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> >   How could it use one generic function for all possible data types,
> > given that the data types can have different sizes and even have completely
> > different implementations for their operators, etc?

> Plain ordinary OOP manages to do this without difficulty.

  At the cost of increased memory consumption (by a rather large factor)
and decreased performance. Plus it's difficult to make it work for native
types (at least with any kind of efficiency).

> ...so templates are like a kind of less-stupid macro expansion system?

  I suppose you could think of them like that. Of course it's not the
whole story.

  (One example of templates being different from preprocessor macros
is that when you instantate a template function or class, it creates
an actual type, with a type name which the linker will see. Preprocessor
macros don't do that.)

> >   It depends on the compiler. Some compilers do insert checks in debug
> > mode.

> Mmm, OK. Well my only experience with writing C is Borland's C compiler 
> for MS-DOS. (Actually, that's a lie. It was a C++ compiler, but we only 
> wrote C.)

  For example Visual C++ adds lots of checks into the compiled code in
debug mode (for example iterator range checks, vector bounds checks, etc).

  Not every memory error can be caught with it, though. But then you can
use a good profiler for the rest.

-- 
                                                          - Warp


Post a reply to this message

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