POV-Ray : Newsgroups : povray.off-topic : Standard libraries : Re: Standard libraries Server Time
6 Sep 2024 13:20:17 EDT (-0400)
  Re: Standard libraries  
From: Warp
Date: 8 Mar 2009 15:23:29
Message: <49b41b31@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> It doesn't really look like the type information lets you do much with the 
> contents of the type. It doesn't tell you anything about the type - it just 
> tells you the ID of the type. It doesn't tell you how big it is, or which 
> members are pointers, or anything like that that would let you do something 
> like serialize the data out to a file. That's usually what I think of when I 
> hear "run-time type information". Not "I can compare two values in a 
> statically-typed language and see if they're the same type." :-)

  "Doing something depending on which type of object *this is" is precisely
what virtual functions are for, and that's the RTTI C++ has. Additionally,
you can get a unique ID for each type of object (resolvable at runtime,
as demonstrated), if you find a use for that. (One possible use could be
that objects could register themselves to some centralized, non-template
factory, using their own typeid as key, so that the factory could create
clones of those objects at runtime, based on those typeids.)

  "It doesn't tell you how big it is, or which members are pointers, or
anything like that" doesn't sound very OO to me. The whole idea of objects
is that they are abstract: You don't know what they have inside, nor do
you even need to know.

  I surely can understand why such information could sometimes be useful,
but it still sounds to me like you are accessing the internals of an object,
bypassing its public interface, which is something that breaks the basic
idea of modularity.

-- 
                                                          - Warp


Post a reply to this message

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