Skip to content

Fix #10648: Fixes of syntax documentation #10658

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

Merged
merged 11 commits into from
Dec 9, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 4, 2020

Fix documentation about indentation syntax. Also fix syntax summary (globally).

The fixes omit documenting : in extension blocks. These are disabled
in a separate commit.

There are two reasons for omitted in : in extensions:

  • they are not needed, and there should be one way to do things
  • they are confusing since everywhere else a : at eol starts a
    new scope, but here it doesn't.

@odersky odersky linked an issue Dec 4, 2020 that may be closed by this pull request
@odersky
Copy link
Contributor Author

odersky commented Dec 4, 2020

There are now two syntax.md files, one in docs/reference, the other in docs/internal.

  • The file in docs/reference contains only the official 3.0 syntax and omits the column with tree node info.
  • The file in docs/internal contains also deprecated and experimental syntax and adds the tree node info column.

It will be a bit painful to keep the two in sync, but it's better to have amn official, stable syntacx summary in the official documentation.

@odersky odersky changed the title Fix #10648 Fix #10648: Fixes of syntax documentation Dec 4, 2020
@odersky odersky requested a review from b-studios December 4, 2020 17:19
@odersky odersky force-pushed the fix-#10648 branch 3 times, most recently from 974cf5c to 44514a3 Compare December 4, 2020 21:26
Copy link
Contributor

@b-studios b-studios left a comment

Choose a reason for hiding this comment

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

Copying the two syntax documents indeed leads to additional maintenance effort. Should we just present the diff in internals and link to the official one?

@@ -1,6 +1,6 @@
---
layout: doc-page
title: "Scala Syntax Summary"
title: "Scala3 Syntax Summary"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
title: "Scala3 Syntax Summary"
title: "Scala 3 Syntax Summary"

@@ -190,7 +190,7 @@ object ExtensionMethods {
// See the documentation of `memberSignature` to understand why `.stripPoly.ensureMethodic` is needed here.
candidates filter (c => FullParameterization.memberSignature(c.info) == imeth.info.stripPoly.ensureMethodic.signature)
assert(matching.nonEmpty,
i"""no extension method found for:
i"""no extension method found for
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an accidental change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted. Yes, that was my regex search misfiring...

RefinedType ::= AnnotType {[colonEol] Refinement}
Template ::= InheritClauses [colonEol] [TemplateBody]
EnumDef ::= id ClassConstr InheritClauses [colonEol] EnumBody
Packaging ::= ‘package’ QualId [nl | colonEol] ‘{’ TopStatSeq ‘}’
Copy link
Contributor

Choose a reason for hiding this comment

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

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's in possibleTemplateStart(). I added a test to verify that : is indeed significant.

@@ -23,7 +23,7 @@ object Main {
21 | println(1 appendS 2)
| ^^^^^^^^^
|value appendS is not a member of Int.
|An extension method was tried, but could not be fully constructed:
Copy link
Contributor

Choose a reason for hiding this comment

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

Like the change in the source, is this intended?

@odersky odersky force-pushed the fix-#10648 branch 3 times, most recently from 327f7ab to 06abeb7 Compare December 9, 2020 11:54
@b-studios
Copy link
Contributor

@odersky there are also still occurrences of : in the documentation on extension methods. I can fix those and push to this branch if you want.

@odersky
Copy link
Contributor Author

odersky commented Dec 9, 2020

@b-studios I think I got them all now. I was looking for " extension.*:$" so extensions starting in the first column slipped through.

@@ -103,7 +103,7 @@ a single extension and enclose all methods in braces or an indented region follo
Example:
Copy link
Contributor

Choose a reason for hiding this comment

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

The text above this line would also need to be adjusted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted. I'll update the doc.

@odersky odersky force-pushed the fix-#10648 branch 2 times, most recently from c2d80fa to 943bf9e Compare December 9, 2020 14:29
The fixes omit documenting `:` in extension blocks. These will be disabled
in a separate commit.

There are two reasons for omitted in `:` in extensions:

 - they are not needed, and there should be one way to do things
 - they are confusing since everywhere else a `:` at eol starts a
   new scope, but here it doesn't.
@odersky odersky merged commit 663d334 into scala:master Dec 9, 2020
@odersky odersky deleted the fix-#10648 branch December 9, 2020 21:20
@japgolly
Copy link
Contributor

japgolly commented Dec 9, 2020

they are confusing since everywhere else a : at eol starts a new scope, but here it doesn't.

I'm trying hard to understand this reasoning but I can't make sense of it. Pretty much everywhere else we have trailing :s, what's special about extension blocks? Even the comment above that it doesn't create a new scope makes no sense to me. But.... of course it creates a new scope. Everything indented under extension is defined within that extension scope. I'm sure the back and forth much be annoying but I urge you to please reconsider this. I can't explain emphatically enough how confusing this is.

@b-studios b-studios mentioned this pull request Dec 10, 2020
16 tasks
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation is unclear about new brace-less syntax
4 participants