Skip to content

Clarify blog post about extension methods #5771

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 1 commit into from
Jan 22, 2019
Merged

Conversation

LPTK
Copy link
Contributor

@LPTK LPTK commented Jan 22, 2019

No description provided.

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

Copy link
Contributor

@biboudis biboudis left a comment

Choose a reason for hiding this comment

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

I like the revision. I see the value of putting the Ext Methods & Type Classes example, however I think the example is coming up to fast and could confuse a reader. This is just the announcement after all and extension methods is a general feature.

@LPTK
Copy link
Contributor Author

LPTK commented Jan 22, 2019

@biboudis
IMHO the significance of Dotty's extension methods is not that they use less boilerplate than implicit classes. Indeed, the reason the community has been so excited about them is that they allow straightforward type class definitions with infix syntax, which is a huge improvement. People reading this need to know that we didn't just "copy C#", and that extension methods in Dotty are way more general and useful (almost a game changer, I'd say).

@biboudis
Copy link
Contributor

biboudis commented Jan 22, 2019

My observation is just that we shouldn't jump from the simplest case of Circle into type classes' definitions with natural syntax without passing first from extension methods defined in a trait and generic extension methods. Essentially we would need to reproduce the documentation Community members know, new users are motivated when they map new concepts to stuff they already know ;-)

However since I am a strong advocate of examples I wouldn't contest to remove it.

WDYT about putting a minor comment below the Circle example saying something like:

Extension methods can be:

  • visible under a simple name (like in the Circle example above)
  • enclosed in a trait and enabled by bringing them in scope
  • polymorphic
  • used to support type class definitions with natural/infix syntax

@LPTK
Copy link
Contributor Author

LPTK commented Jan 22, 2019

I wouldn't contest to remove it.

I'm not sure to understand if you're proposing to remove the type class example or not.

WDYT about putting a minor comment below the Circle example

Sure, why not. But I'm not sure why list "polymorphic". All methods can be polymorphic, it's not a special thing of extension methods. Or maybe you mean something else? Also, why make a difference between "visible under a simple name" and "enabled by bringing them in scope"? And why "enclosed in a trait" when they can be enclosed in anything (trait, class, object...)? Wouldn't it be simpler to just say "enabled when in scope"?

@biboudis
Copy link
Contributor

I'm not sure to understand if you're proposing to remove the type class example or not.

Not anymore. Don't remove it. Just introduce it better with a small comment like the one above and we are good.

Wouldn't it be simpler to just say "enabled when in scope"?

Sound's good, it is also different with other practices after all ;-)

@LPTK
Copy link
Contributor Author

LPTK commented Jan 22, 2019

@biboudis done!

Please, let's try to merge this sooner than later, while the blog post is still being read by people; because as it is now, it contains a pretty obscure and incomplete presentation of extension methods.

@biboudis biboudis merged commit 7c9401f into scala:master Jan 22, 2019
@biboudis
Copy link
Contributor

Looks good. Merged.

Obscurity wasn't intended (you rephrased sentences perfectly!), incompleteness was.
It is the announcement of a feature. The rest are discussed at the documentation.

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.

4 participants