Compile-time match expression #11825
Replies: 4 comments
-
I think compile-time BTW if we implement #8543 and generalise $if field.Type in string | int | rune | bool {
result.$(field.name) = $('get_' + field.Type.name)(data, field.name)
} |
Beta Was this translation helpful? Give feedback.
-
I agree with @ntrel I feel like having just compile time $ifs will make the language simpler. |
Beta Was this translation helpful? Give feedback.
-
Simpler, but a lot more verbose if you have a complex if/else if/else if/else if/else if/... Just think of how "messy" a large if/else block looks compared to a |
Beta Was this translation helpful? Give feedback.
-
I personally feel like it's "simple" for any runtime expression to be easily factored into a comptime expression assuming that the values it operates on are all compile-time known. If If |
Beta Was this translation helpful? Give feedback.
-
We currently only have compile-time if statetemts to check for a type in situations like these:
A compile-time match expression is way better suited for this and more readable imho.
Beta Was this translation helpful? Give feedback.
All reactions