Hacker News new | ask | show | jobs
by jwatte 4081 days ago
Still no support for static compile and runtime introspection. That could be easily and cheaply implemented, at least for POD and aggregates thereof.

If I have to build one more system that requires either a custom parser or repeating the names of all members, I think I will cry. The compiler ALREADY KNOWS!

5 comments

There's actually an official "study group" looking at compile time refection proposals, so this is definitely something in the works. However, the proposals have ranged from mediocre to downright horrible so it's probably not going to be in the standard any time soon.

Some light reading

  [1] (static if) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3613.pdf
  [2] (call for compile-time reflection) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3814.html
  [3] (enum properties queries) http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3815.html
  [4] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3996.pdf
I am very much in support of this. Not for games but serialization. Pretty surprised that there don't seem to be any compiled languages supporting static compile time reflection. I think D does, but that is it.
The latest mailing (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/#mai...) includes several new reflection proposals. N4447 probably covers what you want (although I'm not a huge fan of it).
One (longish) shortcut is getting the info from the debugger which already knows. That is, in the build system, compiling a file #including what you want, firing a debugger, printing out the necessary type information, generating code, building that code with the rest of your system.
Static introspection is available via third party libraries such as Boost.Fusion.