Skip to content

Update and fix the generic extension methods document and the RC1 release blog #11451

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

Conversation

ShapelessCat
Copy link
Contributor

@ShapelessCat ShapelessCat commented Feb 18, 2021

  • I update the extension-methods.md and the corresponding part in the 2021-02-17-scala3-rc1.md.
    The only if in this paragraph

    By contrast, type arguments matching type parameters following extension can be passed only if the method is referenced as a non-extension method

    is not right. Now it supports 4 different forms of call

  • I update the extension-methods.md, and make it consistent with the corresponding part in the 2021-02-17-scala3-rc1.md.

  • Change the level of headings in 2021-02-17-scala3-rc1.md.

    • About the level of headings:
      the markdownlint of my editor tells me we shouldn't use multiple top level headings in one file.
      I'm not sure if this follows our convention for the release blog article. If we want to keep using multiple top level headings, please tell me, and I can revert this change.

@odersky
Copy link
Contributor

odersky commented Feb 18, 2021

is not right. Now it supports 4 different forms of call, as an extension method or not:

Strictly speaking the "only if" is correct. The other two forms of call parameterize the argument to the extension method, not the method itself. But maybe that's hair-splitting. I like the proposed alternative.

@odersky odersky assigned anatoliykmetyuk and unassigned odersky Feb 18, 2021
@ShapelessCat
Copy link
Contributor Author

Can we merge this one?

@anatoliykmetyuk
Copy link
Contributor

is not right. Now it supports 4 different forms of call, as an extension method or not:

Strictly speaking the "only if" is correct. The other two forms of call parameterize the argument to the extension method, not the method itself. But maybe that's hair-splitting. I like the proposed alternative.

I do not think this is hairsplitting, I think this is pretty important. We are parameterising precisely the argument and not extension method. It is the same thing as to say, “there are two ways to provide type parameters to a method, f[String](x) and f(x: String)”. Which can lead to wrong results in case of more complex type inference. E.g.:

def f[T](x: T, y: T): T = y
val x = "foo"
val y = 10

f[String](x, y)  // error
f(x: String, y)  // no error, inferred type is Any

We should not mislead people in our docs.

Copy link
Contributor

@anatoliykmetyuk anatoliykmetyuk left a comment

Choose a reason for hiding this comment

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

(see above comment)


- When the method is referenced as an extension method:

```scala
List("a", "bb", "ccc").sumBy[Int](_.length)
```
Copy link
Member

Choose a reason for hiding this comment

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

Looks good, this change should be applied to the blog also.

- Adjust the markdown to follow markdown style conventions
- Synchronize the document "Extension Methods" with the blog article
  "Scala 3.0.0-RC1 - first release candidate is here"
@ShapelessCat ShapelessCat force-pushed the fix-and-imrpove-extension-methods-docs branch from 416f4f5 to 2603848 Compare March 7, 2021 10:51
@ShapelessCat
Copy link
Contributor Author

ShapelessCat commented Mar 7, 2021

is not right. Now it supports 4 different forms of call, as an extension method or not:

Strictly speaking the "only if" is correct. The other two forms of call parameterize the argument to the extension method, not the method itself. But maybe that's hair-splitting. I like the proposed alternative.

I do not think this is hairsplitting, I think this is pretty important. We are parameterising precisely the argument and not extension method. It is the same thing as to say, “there are two ways to provide type parameters to a method, f[String](x) and f(x: String)”. Which can lead to wrong results in case of more complex type inference. E.g.:

def f[T](x: T, y: T): T = y
val x = "foo"
val y = 10

f[String](x, y)  // error
f(x: String, y)  // no error, inferred type is Any

We should not mislead people in our docs.

Thanks! @anatoliykmetyuk

I think I misunderstood the document, and I wasn't clear about the concepts.
Now I understand what you mean.

I just update this PR and revert the change about generic extension methods in 2021-02-17-scala3-rc1.md.
Now the only change in extension-methods.md is that I modify it to make it consistent with the corresponding part in 2021-02-17-scala3-rc1.md.

# Settling on `scaladoc` as the documentation tool
We have settled on using the well-known `scaladoc` as a name for the documentation tool for Scala 3 (known previously as `scala3doc`).. The obsolete `dotty-doc` (or `scala3-doc`) is removed in RC1. We have also removed all the Kotlin dependencies (Dokka, etc.) from scaladoc. For details, see [PR #11349](https://github.com/lampepfl/dotty/pull/11349). To read more about `scaladoc`, see [documentation](https://dotty.epfl.ch/docs/usage/scaladoc/index.html)
## Settling on `scaladoc` as the documentation tool

Copy link
Contributor

Choose a reason for hiding this comment

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

What's the motivation behind using heading level 2 instead of 1 and leaving a newline?

Copy link
Contributor

@michelou michelou Mar 8, 2021

Choose a reason for hiding this comment

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

@anatoliykmetyuk I invite you to look at the Google Style Guide, for instance the section Add spacing to headings.
IMO the best choice would be to adher to an existing style guide or (at least) to agree on a minimal set of rules which work both with Scaladoc and with tools such as Pandoc (see PR #11257).

If you have questions or any sort of feedback, feel free to send us a message on our
[Gitter channel](https://gitter.im/lampepfl/dotty). If you encounter a bug, please
[open an issue on GitHub](https://github.com/lampepfl/dotty/issues/new).

### Contributors
Copy link
Contributor

Choose a reason for hiding this comment

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

Why 3rd header level here? In all blog articles, this item is a top-level header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anatoliykmetyuk anatoliykmetyuk merged commit c414e8c into scala:master Mar 10, 2021
@ShapelessCat ShapelessCat deleted the fix-and-imrpove-extension-methods-docs branch March 15, 2021 21:09
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.

5 participants