Hacker News new | ask | show | jobs
by tsimionescu 442 days 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)?
2 comments

Not 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.

According to 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.