I think it makes perfect sense to allow optional braces after any operator. I hope this will include non-symbolic operators. This way, one can define an of
operator, useful for its low precedence, to do the same as the proposed <|
, as in
def constrExpr(): Tree =
if in.isNestedStart then
atSpan(in.offset) of
inBracesOrIndented of
val stats = selfInvocation() ::
if isStatSep then { in.nextToken(); blockStatSeq() }
else Nil
Block(stats, unitLiteral)
else
Block(selfInvocation() :: Nil, unitLiteral)
If we go to the logical conclusion of this approach, we can arrive at a definitive fix for postfix operators: indentation lets us determine what is or is not an argument to trailing operators:
foo tap
println
// i.e.,
foo.tap {
println
}
xs map f toSet
ys
// i.e.,
xs.map(f).toSet
ys
xs map f toSet
ys
// i.e.,
xs.map(f).toSet {
ys
}