Skip to content

Commit 921e63f

Browse files
committed
Remove old mention of the fewerBraces
1 parent 8f8c3a4 commit 921e63f

File tree

1 file changed

+0
-59
lines changed

1 file changed

+0
-59
lines changed

docs/_docs/reference/other-new-features/indentation.md

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -502,62 +502,3 @@ indented regions where possible. When invoked with options `-rewrite -no-indent`
502502
The `-indent` option only works on [new-style syntax](./control-syntax.md). So to go from old-style syntax to new-style indented code one has to invoke the compiler twice, first with options `-rewrite -new-syntax`, then again with options
503503
`-rewrite -indent`. To go in the opposite direction, from indented code to old-style syntax, it's `-rewrite -no-indent`, followed by `-rewrite -old-syntax`.
504504

505-
### Variant: Indentation Marker `:` for Arguments
506-
507-
Generally, the possible indentation regions coincide with those regions where braces `{...}` are also legal, no matter whether the braces enclose an expression or a set of definitions. There is one exception, though: Arguments to functions can be enclosed in braces but they cannot be simply indented instead. Making indentation always significant for function arguments would be too restrictive and fragile.
508-
509-
To allow such arguments to be written without braces, a variant of the indentation scheme is implemented under language import
510-
```scala
511-
import language.experimental.fewerBraces
512-
```
513-
In this variant, a `<colon>` token is also recognized where function argument would be expected. Examples:
514-
515-
```scala
516-
times(10):
517-
println("ah")
518-
println("ha")
519-
```
520-
521-
or
522-
523-
```scala
524-
credentials `++`:
525-
val file = Path.userHome / ".credentials"
526-
if file.exists
527-
then Seq(Credentials(file))
528-
else Seq()
529-
```
530-
531-
or
532-
533-
```scala
534-
xs.map:
535-
x =>
536-
val y = x - 1
537-
y * y
538-
```
539-
What's more, a `:` in these settings can also be followed on the same line by the parameter part and arrow of a lambda. So the last example could be compressed to this:
540-
541-
```scala
542-
xs.map: x =>
543-
val y = x - 1
544-
y * y
545-
```
546-
and the following would also be legal:
547-
```scala
548-
xs.foldLeft(0): (x, y) =>
549-
x + y
550-
```
551-
552-
The grammar changes for this variant are as follows.
553-
554-
```
555-
SimpleExpr ::= ...
556-
| SimpleExpr ColonArgument
557-
InfixExpr ::= ...
558-
| InfixExpr id ColonArgument
559-
ColonArgument ::= colon [LambdaStart]
560-
indent (CaseClauses | Block) outdent
561-
LambdaStart ::= FunParams (‘=>|?=>’)
562-
| HkTypeParamClause=>
563-
```

0 commit comments

Comments
 (0)