3 ms·
Did they have to invent new syntax for it? All other languages that have reflection have regular function calls for it. Why do ^^X instead of reflect(X)?
by tsimionescu 2y ago
Did they have to invent new syntax for it? All other languages that have reflection have regular function calls for it. Why do ^^X instead of reflect(X)?
- gpderetta 2y agoNot very many languages have compile time reflection. This is more like macros and syntax splicing. Still a reflect keyword could have worked. Some argued that in reflection heavy code you would reflect a lot and the keyword would be a lot of noise. I don't know if the reflection papers have been voted in already (I forgot how to check), so the syntax might still be up for debate.
- edflsafoiewq 2y agoAccording to https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2996r10.html#syntax-discussion https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p29... > The original TS landed on reflexpr(...) as the syntax to reflect source constructs and [P1240R0] adopted that syntax as well. As more examples were discussed, it became clear that that syntax was both (a) too “heavy” and (b) insufficiently distinct from a function call. SG7 eventually agreed upon the prefix ^ operator. The “upward arrow” interpretation of the caret matches the “lift” or “raise” verbs that are sometimes used to describe the reflection operation in other contexts.