3 ms·
I'm in the opposite camp, runtime reflection is useless, and almost always points to a design flaw while compile time reflection is actually useful (for obvious
by flohofwoe 2y ago
I'm in the opposite camp, runtime reflection is useless, and almost always points to a design flaw while compile time reflection is actually useful (for obvious things like automatically building a serialization layer or an UI which represents the type, or building types from other types).
I'm sure that C++26 has implemented it in a way which is highly unpleasant to use though ;)
- deleted 2y ago[deleted]
- jcranmer 2y agoThe element of runtime reflection that is the most useful is something along the lines of "here's function, here's a list of arguments, go call this function with those arguments".
- xmcqdpt2 2y agoHaving to do this by reflection is a problem in principle solvable by types. Here is a function of type (A, B, C) => R, and here is a tuple of arguments of type (A, B, C), go call this function with those arguments. Most programming languages make it hard to easily express those constraints so reflection is used instead.