Should if|for|while|match statements allow multiline expressions? #9516
bitwise-aiden
started this conversation in
Scripting
Replies: 3 comments 11 replies
-
For if you have a documented solution: if a or \
b: |
Beta Was this translation helpful? Give feedback.
3 replies
-
For if (
some_long_predicate or
some_other_long_predicate
):
pass
while (
some_long_predicate or
some_other_long_predicate
):
pass |
Beta Was this translation helpful? Give feedback.
1 reply
-
I agree that godotengine/godot#90373 is ok because parentheses are used (whether it's |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
After shipping this change to match patterns to allow multiline expression in dictionary and array patterns I found another surprising case where I expected multiline:
After some thinking it through it is inline with how
if|for|while
and even the expression of thematch
statement behave. Though given there is a clear<keyword> <expression>:
or<expression>:
pattern for defining these statements does it make sense to keep this constraint / is there any functional reason that we can't open up the parser to allow for multiline expressions in these definitions?It looks like this has been discussed a bit before specifically for the code that lead me here (#2201), but I think that there may be room for a broader discussion about allowing for this pattern to be consistent across the board. Especially now that you can have pseudo new lines with match statements thanks to my previous PR.
Some of the other examples:
Beta Was this translation helpful? Give feedback.
All reactions