www.digitalmars.com         C & C++   DMDScript  

D - Exposing Type Information to Runtime Code

reply Russ Lewis <spamhole-2001-07-16 deming-os.org> writes:
IMHO, you should be able to discover all of the information about
variables and their types at runtime.

Now, before everybody gets antsy, I'm not talking about embedding it in
the variables themselves, nor even requiring that the programmer use
it.  But I think that you should be able to write a line something like:

    MyClass.type  ......

Which gives you access to a tree of data that describes everything about
that type - its members, their properties, etc.

If you don't use access it, then the compiler doesn't have to generate
it for your program.  But if you do use it, it is far more maintainable,
readable, and cross-portable than any other solution I've found so far.

--
The Villagers are Online! villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]
Jul 09 2002
next sibling parent reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
Not only at runtime, this kind of info can really help you write nice
template code.  At very very least you need typeof(), sizeof(), and
offsetof().

Sean


"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3D2B29A8.64BF8A8F deming-os.org...
 IMHO, you should be able to discover all of the information about
 variables and their types at runtime.

 Now, before everybody gets antsy, I'm not talking about embedding it in
 the variables themselves, nor even requiring that the programmer use
 it.  But I think that you should be able to write a line something like:

     MyClass.type  ......

 Which gives you access to a tree of data that describes everything about
 that type - its members, their properties, etc.

 If you don't use access it, then the compiler doesn't have to generate
 it for your program.  But if you do use it, it is far more maintainable,
 readable, and cross-portable than any other solution I've found so far.
Jul 09 2002
parent Pavel Minayev <evilone omen.ru> writes:
On Tue=2C 9 Jul 2002 22=3A44=3A31 -0700 =22Sean L=2E Palmer=22
=3Cseanpalmer=40earthlink=2Enet=3E 
wrote=3A

=3E Not only at runtime=2C this kind of info can really help you write nice
=3E template code=2E  At very very least you need typeof=28=29=2C
sizeof=28=29=2C and
=3E offsetof=28=29=2E

You have 'em=3A

=09object=2Eclassinfo
=09object=2Esize
=09struct=2Efield=2Eoffset
Jul 20 2002
prev sibling parent "Walter" <walter digitalmars.com> writes:
It is a good idea, and it is where ClassInfo and TypeInfo are heading.
However, they are not there yet, for the reason that I don't want to stuff
those with things I imagine might be useful, but instead I'll put in things
as significant needs for them become apparent. Both will likely play a
significant role in future generic type design for D.

-Walter

"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message
news:3D2B29A8.64BF8A8F deming-os.org...
 IMHO, you should be able to discover all of the information about
 variables and their types at runtime.

 Now, before everybody gets antsy, I'm not talking about embedding it in
 the variables themselves, nor even requiring that the programmer use
 it.  But I think that you should be able to write a line something like:

     MyClass.type  ......

 Which gives you access to a tree of data that describes everything about
 that type - its members, their properties, etc.

 If you don't use access it, then the compiler doesn't have to generate
 it for your program.  But if you do use it, it is far more maintainable,
 readable, and cross-portable than any other solution I've found so far.

 --
 The Villagers are Online! villagersonline.com

 .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
 .[ (a version.of(English).(precise.more)) is(possible) ]
 ?[ you want.to(help(develop(it))) ]
Jul 19 2002