-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
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 😄 |
I'm reviewing this next Monday and I'll give @soronpo some feedback on the motivation as we discussed privately. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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:
- Can you elaborate on why developers expect that?
- Perhaps also make a point to make the language more consistent?
- Can you explain in which use cases or domain are prefix types more likely to be useful?
- Can you come up with more interesting and shorter examples that show the value of prefix types?
- 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
As requested by the October 2017's SIP committee, the SIP was split into two: