473,414 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Introspection Guidelines for C++?

I suspect the core language is not the level at which introspection should
be implemented in C++. That has been the choice of C#, and Java. Both of
these languages made some trade-offs to accomplish this. Like threading,
introspection can probably be implemented by third party providers. I tend
to favor open standards that are acceptted and respected by a significant
portion of the developers working in the field. Stroustrup states the
chance of providing type information in such a way that would satisfy
everybody is zero. I will point out that he makes this assertion in the
context of discussing the very primitive, but extensible runtime type
information mechanism in C++. I think it's wise to try to provide an
introspection mechanism that is intended to satisfy the most of the needs
of a significant number of developers rather than trying to attempt the One
True Solution.

I was thinking earlier today about what it would take to implement such a
thing using the preprocessor techniques people have been advocating on the
newsgroup in the past few days. Not that I think it's the right solution.
I just tend to approach things from many different directions.

The way Java and C# provide introspection is through the use of a universal
base class. That's a non-starter for C++. That doesn't mean their
approaches can't be examined in terms of what they provide, or even with a
view toward implementing a subset of all classes using introspection.

I once proposed splitting structs and classes in such a way that structs
would not provide introspection, while classes would. That didn't fly, but
the concept of providing it for some, but not all classes still makes
sense. The basic problem with using a UBC as a means to provide
introspection is that you take a hit on overhead, both in terms of space,
and performance. It also means that you don't have the flexibility to
employ mixed solutions in which some of your classes use one mechanism, and
some use another. (Unless you are willing to accept the unused excess
baggage.)

The reason I mentioned using preprocessing to provide introspection is that
it could probably be done in such a way that you would incur less overhead.
I also know that Trolltech provides a modest form of introspection using
the moc in proprocessing.

My gut instinct tells me templates are really the way to go for a lot of
this. If we could get some kind of compile-time 'stringization' using
templates, in such a way that the resulting code would not have the same
potential for unexpected results that macro code has, we could probably do
a lot with them. Things like compiling in the fully qualified class name,
function signatures, and other descriptive information of a class in such a
way that it would not require the programmer to hand code it all.

After I recover from my very frustrating day trying to work with Boost's
test library, I might even suggest that would be a good place to put a
library that supports introspection.
--
"[M]y dislike for the preprocessor is well known. Cpp is essential in C
programming, and still important in conventional C++ implementations, but
it is a hack, and so are most of the techniques that rely on it. ...I think
the time has come to be serious about macro-free C++ programming." - B. S.

Jul 22 '05 #1
0 1389

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rim | last post by:
Hi, Is there a way to get any sort of introspection which would return the content of an instance *in the order they were declared or executed* as opposed to alphabetical order? Example: ...
2
by: Vsevolod (Simon) Ilyushchenko | last post by:
Hi, Last year I have written a Perl module to serve as a backend to Macromedia Flash applications: http://www.simonf.com/amfperl I have just rewritten it in Python, which I have not used...
4
by: Benjamin Rutt | last post by:
I'm trying to learn about introspection in Python. my ultimate goal is to be able to build a module "text database" of all modules that are in the sys.path, by discovering all candidate modules...
4
by: Steven T. Hatton | last post by:
Has there been any substantial progress toward supporting introspection/reflection in C++? I don't intend to mean it should be part of the Standard. It would, nonetheless, be nice to have a...
1
by: James Geurts | last post by:
Hi, Can someone tell me how to test if a field is a const? I am using the FxCop introspection engine, but I suppose I could use reflection if required. for example, the following would return...
2
by: greg.corson | last post by:
Hi, I'm in the process of building a complex system using a sort of "system services" model. I'm looking at putting together various services like serialization, networking, 2D/3D rendering,...
8
by: R. Bernstein | last post by:
In doing the extension to the python debugger which I have here: http://sourceforge.net/project/showfiles.php?group_id=61395&package_id=175827 I came across one little thing that it would be nice...
3
by: James Stroud | last post by:
Hello, I wanted to automagically generate an instance of a class from a dictionary--which might be generated from yaml or json. I came up with this: # automagical constructor def...
14
by: Dave Rahardja | last post by:
Is there a way to generate a series of statements based on the data members of a structure at compile time? I have a function that reverses the endianness of any data structure: /// Reverse...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.