wren
wren copied to clipboard
if/else - docs need to mention that else must follow brace on the same line
From the wren html doc page on control flow:
if (ready) {
System.print("go!")
} else {
System.print("not ready!")
}
This compiles and executes as expected.
However, with the else statement on the next line, we get an error.
from my module file: clip.wren
if (ready) {
System.print("go!")
}
else {
System.print("not ready!")
}
error output when trying to load the module:
wren v0.4.0
> import "./clip"
[./clip line 4] Error at 'else': Expected expression.
[./clip line 4] Error at '{': Expect end of file.
Runtime error: Could not compile module './clip'.
If the compile error is the intended behavior, then perhaps we need to update the doc page with some advice or a warning: doc: https://wren.io/control-flow.html
It is currently intended and required to be on the same line yea.
Removing that requirement could be easily implemented (like it was done for the '.' after new line) it is only a political decision/design choice.
yea @mhermier I've been experimenting with it in luxe for a while looking for edge cases in daily use, I think there's value in reducing friction for the 99% when a 0.1% of use case can cause confusion. I'd rather the confusion be on the small subset than the majority so I'm revisiting this in practice at scale with many users
@ruby0x1 Any update of this?