Skip to content

Add @infix annotation #5975

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 13 commits into from
May 15, 2019
Merged

Add @infix annotation #5975

merged 13 commits into from
May 15, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 23, 2019

An elaboration of the proposal made by @sjrd in #5937. @alpha will come in a separate PR.

@odersky
Copy link
Contributor Author

odersky commented Feb 23, 2019

Current status: The new annotations are defined and explained, but the compiler does not interpret them yet.

@odersky odersky force-pushed the add-infix branch 5 times, most recently from 6e95d4d to 0cfd797 Compare February 23, 2019 11:44
2. An `@alpha` annotation can be given for all kinds of definitions.

3. The name given in an `@alpha` annotation must be a legal name
for the defined entities on the host platform.
Copy link
Member

Choose a reason for hiding this comment

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

We should not rely on "the host platform"'s notion of a legal name. Scala code should equally compile on all platforms. So this should be defined here (potentially as a valid Java identifier name).

s1 difference s2 // gives a deprecation warning

s1 * s2 // OK
s1.*(s2) // also OK, but unusual
Copy link
Member

Choose a reason for hiding this comment

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

The two "also OK" cases (s1.union(s2) and s1.*(s2)) kind of go against the motivation of achieving consistency. For consistency to be really applied, they should give a deprecation warning.

Copy link
Contributor Author

@odersky odersky Feb 25, 2019

Choose a reason for hiding this comment

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

Yes, it's a tradeoff. I believe though that declaring something @infix would be a strong enough social cue that people would follow it without the compiler having to enforce it. Always allowing method call syntax has the advantage that we can normalize programs. We can say x union y desugars to x.union(y). If x.union(y) was not legal that explanation would not be available.

Copy link
Member

Choose a reason for hiding this comment

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

Meh. Yes, OK.

@odersky odersky force-pushed the add-infix branch 2 times, most recently from c94792c to 68ebca8 Compare April 19, 2019 13:19
@odersky odersky changed the title Fix #5937: Add @infix and @alpha annotations Add @infix annotation Apr 20, 2019
@odersky
Copy link
Contributor Author

odersky commented Apr 20, 2019

The @infix part is done now.

@odersky odersky merged commit 206fa7c into scala:master May 15, 2019
@allanrenucci allanrenucci deleted the add-infix branch May 15, 2019 19:33
@anatoliykmetyuk anatoliykmetyuk added this to the 0.15 Tech Preview milestone May 21, 2019
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