adjtr
September 20, 2020, 6:15pm
1
Under the new, brace-free syntax, what is the rationale for the keyword “then” in an if statement? Isn’t it cleaner to use the semicolumn such as in a class definition to avoid having multiple different end of line markers? For instance:
if something:
doIt()
Same question for loops (eg while do).
3 Likes
LPTK
September 21, 2020, 10:36am
2
You want to use the same syntax for in-line expressions, but if A: B
would look like a type ascription, when put on the same line.
3 Likes
opened 03:04PM - 07 Sep 20 UTC
This compiles but shouldn't (we should require then when using indentation syntax)
if cond
fooA()
fooB()
This compiles in Scala 2.13 but not...
area:parser
itype:bug
Personally, I hope they allow then
-free and do
-free, as I commented there, but there are competing opinions.
The linked ticket says indentation won’t save us.
opened 01:03PM - 14 Sep 20 UTC
closed 03:11PM - 20 Sep 20 UTC
Minimized code
A sample like this compiles fine:
object A:
def fn: Unit =
if true then
println(1)
else
println(2)
but this one does...
area:parser
itype:bug
I didn’t follow the saga of colon for template definition.
opened 09:05AM - 30 Aug 19 UTC
closed 01:58PM - 18 Nov 19 UTC
The meaning of : for significant indentation is more contentious than other aspects. We should come up with a crisp and...
Colon gets varying degrees of support. I would have expected more people to complain about requiring space between operator chars.
object :+ :
1 Like