 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nicolas Fleury Guest
|
Posted: Wed Oct 22, 2003 8:03 pm Post subject: RTTI? What about CTTI? |
|
|
Hi,
I've seen some discussions about extending current RTTI capabilities on
this newsgroup, but RTTI has a cost at run-time, at least in memory, so
it always difficult to evaluate what should be added. With a proposal
like "metacode", to execute code at compile-time, I wonder if it would
be a could idea to provide compile-time type information (I have no idea
if CTTI is an existing term) that could be useful when, for example,
generating documentation or building layers for other languages (like
Boost.Python). What do you think?
Regards,
Nicolas Fleury
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David Abrahams Guest
|
Posted: Thu Oct 23, 2003 3:00 pm Post subject: Re: RTTI? What about CTTI? |
|
|
Nicolas Fleury <nid_oizo (AT) yahoo (DOT) com_remove_the_> writes:
| Quote: | Hi,
I've seen some discussions about extending current RTTI capabilities on
this newsgroup, but RTTI has a cost at run-time, at least in memory, so
it always difficult to evaluate what should be added. With a proposal
like "metacode", to execute code at compile-time, I wonder if it would
be a could idea to provide compile-time type information (I have no idea
if CTTI is an existing term) that could be useful when, for example,
generating documentation or building layers for other languages (like
Boost.Python). What do you think?
|
You mean like
[url]http://www.mail-archive.com/boost (AT) lists (DOT) boost.org/msg09098.html?[/url]
I'm for it, of course!
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
sashan Guest
|
Posted: Thu Oct 23, 2003 9:18 pm Post subject: Re: RTTI? What about CTTI? |
|
|
Nicolas Fleury wrote:
| Quote: | Hi,
I've seen some discussions about extending current RTTI capabilities on
this newsgroup, but RTTI has a cost at run-time, at least in memory, so
it always difficult to evaluate what should be added. With a proposal
like "metacode", to execute code at compile-time, I wonder if it would
be a could idea to provide compile-time type information (I have no idea
if CTTI is an existing term) that could be useful when, for example,
generating documentation or building layers for other languages (like
Boost.Python). What do you think?
|
gcc implements something called typeof.
http://gcc.gnu.org/onlinedocs/gcc/Typeof.html. It's a non-standard
extension.
--
sashan
http://www.cs.auckland.ac.nz/~sgov008/
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
David B. Held Guest
|
Posted: Fri Oct 24, 2003 12:23 am Post subject: Re: RTTI? What about CTTI? |
|
|
"Nicolas Fleury" <nid_oizo (AT) yahoo (DOT) com_remove_the_> wrote
| Quote: | [...]
(I have no idea if CTTI is an existing term) that could be
useful when, for example, generating documentation or
building layers for other languages (like Boost.Python). What
do you think?
|
I think the term you're looking for is "reflection". You get
some of that with Boost.TypeTraits, but that is obviously
limited by what is allowed in the language (though in some
places, it uses a few suspect tricks that seem to work on
some compilers, but might not be strictly "allowed" by
the language). Static metaprogramming in general (as
opposed to what Lisp does, for instance) in an imperative
language (as opposed to say, Haskell or ML) seems to be
a bit elusive. It's primitive at best in C++, which tells me
that we need "C++ with metaclasses". Who knows...maybe
someone will invent such a language. Whatever it is, I
know that it isn't D. ;)
Dave
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Aaron Bentley Guest
|
Posted: Fri Oct 24, 2003 7:12 pm Post subject: Re: RTTI? What about CTTI? |
|
|
David B. Held wrote:
| Quote: | Static metaprogramming in general (as
opposed to what Lisp does, for instance) in an imperative
language (as opposed to say, Haskell or ML) seems to be
a bit elusive. It's primitive at best in C++, which tells me
that we need "C++ with metaclasses". Who knows...maybe
someone will invent such a language. Whatever it is, I
know that it isn't D.
|
Daveed Vandevoorde is working on a C++ extension called "metacode",
which seems to be along these lines...
http://www.vandevoorde.com/Daveed/News/
Aaron
--
Aaron Bentley
www.aaronbentley.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
stelios xanthakis Guest
|
Posted: Fri Oct 24, 2003 7:24 pm Post subject: Re: RTTI? What about CTTI? |
|
|
Nicolas Fleury <nid_oizo (AT) yahoo (DOT) com_remove_the_> wrote
| Quote: | Hi,
I've seen some discussions about extending current RTTI capabilities on
this newsgroup, but RTTI has a cost at run-time, at least in memory, so
it always difficult to evaluate what should be added. With a proposal
like "metacode", to execute code at compile-time, I wonder if it would
be a could idea to provide compile-time type information (I have no idea
if CTTI is an existing term) that could be useful when, for example,
generating documentation or building layers for other languages (like
Boost.Python). What do you think?
|
Do you mean like C99 __func__?
We could have __class__, __namespace__ and __template__ which shall be
special strings in which the compiler shall put the name of the
current class, namespace, template?
That's an easy solution.
"metacode" on the other hand is more challenging, but ... you
are talking about an interpreter inside the compiler. So this interpreter
should'd better not be a language like C++. It'd better be like python
(without the whitespace damage:). It should also communicate with
the internal parser. And to provide what?... If the only interesting
things are __class__, __template__, __namespace__, __func__ then an
entire interpreter is not worth the trouble. metacode not a good idea IMO.
I hope I understood CTTI.
BTW, RTTI is not just about showing pretty names. It is essential
in implementing dynamic_cast and downcasting in virtual inheritance.
The thing with the names is just an add-on. I'm against that one
too...
stelios.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Nicolas Fleury Guest
|
Posted: Sat Oct 25, 2003 8:30 am Post subject: Re: RTTI? What about CTTI? |
|
|
stelios xanthakis wrote:
| Quote: | Do you mean like C99 __func__?
We could have __class__, __namespace__ and __template__ which shall be
special strings in which the compiler shall put the name of the
current class, namespace, template?
|
A class is not an object in C++ (in comparison with languages like
Python), so suppose your want to iterate through all the classes in a
scope and through all member functions of these classes. The question
is what is done at run-time and what is done at compile-time.
| Quote: | That's an easy solution.
"metacode" on the other hand is more challenging, but ... you
are talking about an interpreter inside the compiler. So this interpreter
should'd better not be a language like C++. It'd better be like python
(without the whitespace damage:). It should also communicate with
the internal parser. And to provide what?... If the only interesting
things are __class__, __template__, __namespace__, __func__ then an
entire interpreter is not worth the trouble. metacode not a good idea IMO.
|
To me, metacode sounds like a kick-ass feature. I'm not sure C++ is a
good metaprogramming language (I would more think about something like
Lisp), but we need a simpler way to do metaprogramming and we need a way
to do more. With other languages rising, C++ is becoming the tool of
choice mainly for system programming, video games, etc. where
performance is very important. What can be more performant at run-time
than doing the maximum at compile-time?
| Quote: | I hope I understood CTTI.
BTW, RTTI is not just about showing pretty names. It is essential
in implementing dynamic_cast and downcasting in virtual inheritance.
The thing with the names is just an add-on. I'm against that one
too...
|
I know, and that's why everything that could be done at compile-time
should. Adding information to RTTI would be a cost to everyone, not CTTI.
Regards,
Nicolas Fleury
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|