Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix example that did not compile and following paragraph #18065

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/_docs/reference/other-new-features/indentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ Indentation can be mixed freely with braces `{...}`, as well as brackets `[...]`
For instance, consider:
```scala
{
val x = f(x: Int, y =>
val x = 4
f(x: Int, y =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a neophyte, I can't tell if : Int is intended.

It would be poetic justice to val x = 3. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works because for example val y = x: Int is valid, it widens the type of the expression to Int

And since you can use arbitrary expressions as parameters, val y = f(x: Int) is valid

Copy link
Contributor

@som-snytt som-snytt Jun 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rephrasing: as a neophyte, : Int is confusing to me. What is it an example of? What does it illustrate? There is no definition of f, is that correct? Therefore, it is not a cut/paste example. Of course, the language reference is permitted to be arbitrarily obscure.

Edit: I should have added, I have no inner need to be right here or to be heard.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was some way to illustrate that the parser isn't treating the argument list like 2 lambda parameters? but its strange to use it there. It probably shouldn't be there unless it specifically illustrates something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I 100% agree, I didn't change it because I wanted this PR to be minimal

I did not look at other parts of this page than the examples either, there might be other improvements possible

x * (
y + 1
) +
Expand All @@ -270,13 +271,13 @@ For instance, consider:
)
}
```
- Here, the indentation width of the region enclosed by the braces is 3 (i.e. the indentation width of the
- Here, the indentation width of the region enclosed by the braces is 2 (i.e. the indentation width of the
statement starting with `val`).
- The indentation width of the region in parentheses that follows `f` is also 3, since the opening
- The indentation width of the region in parentheses that follows `f` is also 2, since the opening
parenthesis is not at the end of a line.
- The indentation width of the region in parentheses around `y + 1` is 9
- The indentation width of the region in parentheses around `y + 1` is 6
(i.e. the indentation width of `y + 1`).
- Finally, the indentation width of the last region in parentheses starting with `(x` is 6 (i.e. the indentation width of the indented region following the `=>`.
- Finally, the indentation width of the last region in parentheses starting with `(x` is 4 (i.e. the indentation width of the indented region following the `=>`.
## Special Treatment of Case Clauses
Expand Down