Skip to content

Split SIP33 into two SIPs #905

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
Nov 29, 2017
Merged

Split SIP33 into two SIPs #905

merged 11 commits into from
Nov 29, 2017

Conversation

soronpo
Copy link
Contributor

@soronpo soronpo commented Oct 25, 2017

As requested by the October 2017's SIP committee, the SIP was split into two:

  1. SIP33 now only specify infix types precedence (maintains its number)
  2. SIPNN (no numbered) specifies prefix types.

@SethTisue
Copy link
Member

@soronpo I'm supposed to make sure that you received the feedback from the SIP committee — apparently you did :-)

could you also take a minute to review the parts of #907 that pertain to your SIP and verify that @darjutak represented them accurately?

@soronpo
Copy link
Contributor Author

soronpo commented Oct 26, 2017

could you also take a minute to review the parts of #907 that pertain to your SIP and verify that @darjutak represented them accurately?

They were represented as commented by the committee (aside for a minor error which I commented on now). Accurately depends on my perspective which might be different than the committee's, but that should not part of the minutes 😄

@jvican jvican self-assigned this Oct 27, 2017
@jvican
Copy link
Member

jvican commented Oct 27, 2017

I'm reviewing this next Monday and I'll give @soronpo some feedback on the motivation as we discussed privately.

@heathermiller
Copy link
Member

(@jvican: @darjutak and I will hold you to it! 😈 )

Copy link
Member

@jvican jvican left a comment

Choose a reason for hiding this comment

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

Hey Oron, I've left you some comments that I think can improve the proposal. Thank you for taking the time to write it up. In general, I think it still needs a little bit of work to convince the Committee that prefix types are not too niche. I think your best card to play is to argue about consistency of the language, but for that you need to ensure that language features are sorted out beforehand and that the compiler knows how to distinguish between type and term operations.


---

## Proposal
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this after the motivation section?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

---

## Motivation
Developers expect terms and types to be expressed the same for mathematical and logical operations.
Copy link
Member

Choose a reason for hiding this comment

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

Reading just this line I have several questions:

  1. Can you elaborate on why developers expect that?
  2. Perhaps also make a point to make the language more consistent?
  3. Can you explain in which use cases or domain are prefix types more likely to be useful?
  4. Can you come up with more interesting and shorter examples that show the value of prefix types?
  5. Can you find other programming languages that support prefix types and tell us about their experience using them?

In my opinion, this motivation is not enough to gauge attention from the Committee... motivations are self-contained explanations that research on why the language is lacking without a certain lanaguage feature. They are usually rich in details and examples, and they try to be as objective as possible. For example, saying "developers expect terms and types to be expressed the same for mathematical and logical operations" is not backed up by any empirical or objective data, and it sounds overly subjective.

I feel that you can make a much better case for prefix types if you turn your statement around: try to go to the data and analysis first, and then you draw some conclusions from there. Prefix types look like a language feature that has not perceived lots of attention in other languages -- in this case, I think it's important to explain in which scenarios (with concrete examples) would they be useful.

Copy link
Contributor Author

@soronpo soronpo Oct 31, 2017

Choose a reason for hiding this comment

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

I understand what you mean. The problem is justifying this can be just as easily a chicken and egg issue. Nobody uses prefix types because they are not available and the alternative is "good enough". Will a survey passed among the community be acceptable by the committee?

I cannot tell the committee it is not a niche because it is. It will only serve the typelevel community, but it enables us to think less about the language, in general. Currently, we have to think differently for typelevel operations, because the language made it different.

Other than the potential for confusion with variance annotation, I don't understand the reluctance to include this feature in the language:

  • Prefix types are not for doing the same thing but different. They add something that we can't do at all.
  • The implementation is very simple and should not affect the compiler in any way.

Copy link
Member

Choose a reason for hiding this comment

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

I understand what you mean. The problem is justifying this can be just as easily a chicken and egg issue. Nobody uses prefix types because they are not available and the alternative is "good enough".

If this hasn't been tested before enough, how are we sure that it merits being accepted in the Scala Language Specification? 😄

Other than the potential for confusion with variance annotation, I don't understand the reluctance to include this feature in the language:

Let's see what the Committee thinks. I'll discuss it with Martin too. Thank you for your feedback and updating this document!


The [singleton-ops library](https://github.com/fthomas/singleton-ops) with [Typelevel Scala](https://github.com/typelevel/scala) (which implemented [SIP-23](http://docs.scala-lang.org/sips/pending/42.type.html)) enable developers to express literal type operations more intuitively. For example:

```scala
Copy link
Member

Choose a reason for hiding this comment

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

Can you add text that complements this snippet of code? For examples, saying "let's define foo and bar for..." or something similar. You can draw inspiration from SIP-35 Opaque types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

type bad = 2 ~~ -2 //Error:(9, 20) ';' expected but integer literal found.
type work_around = 2 ~~ (-2) //works for Typelevel scala, but fails in Dotty
```
It is not yet clear if this is an implementation issue, or if the spec should be changed to allow this as well.
Copy link
Member

Choose a reason for hiding this comment

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

I think it's important that this is sorted out before presenting the proposal to the Committee (you want to give the impression that you've researched and understood future interactions with prefix types). In particular, why is this happening?

You may also ask the Dotty team about more clarifications in the issue tracker if you cannot find the root of the problem. /cc @smarter

Copy link
Contributor Author

@soronpo soronpo Oct 31, 2017

Choose a reason for hiding this comment

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

After investigating this further for TLS, I figured out that the SIP23 proposal (and implementation) should be changed to support infix and negative literal type interaction. Interestingly, implementing prefix types resolves this issue, because a - prefix type has a special case to handle negative literal types. Here is a branch I made that fixes SIP23:
https://github.com/soronpo/scala/blob/3aeb19a7ff9e9c2a1dda61899d4c6482cdd8343e/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala#L1052
You can see that a Spec change is required to handle NegativeNumericLiteral inside a compound type.
The prefix expression implementation does the same thing, so that is why we don't have such a bug with infix expressions and negative literal values.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that SIP-23 should handle negated numeric literal types more smoothly than it does at present (see the example at the head of typelevel/scala#157). However I think that the prefix type proposal goes beyond and is somewhat orthogonal to this, so I think it deserves a separate SIP.

Copy link
Member

Choose a reason for hiding this comment

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

@soronpo Can you update this last part and we merge? Thanks for your hard work Oron.

@jvican jvican merged commit 9acaa81 into scala:master Nov 29, 2017
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