-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add compiletime.ops.string.CharAt #14431
Add compiletime.ops.string.CharAt #14431
Conversation
The implementation LGTM. |
In my mind length and charAt are the two string primitives that one needs to analyze strings. They give an array-like view that is rather universal, and work pretty well with our current support for type-level integers. In terms of use-case, I've been working on a regex library with type- and null-safe capture groups. It analyses string with recursive match types, and it's only missing |
OK. From the milestones I'm guessing that the compiler team is getting ready for 3.2.0-RC1. |
Sounds good, I'll update the PR! |
f08e8c0
to
62cf1c6
Compare
I updated the annotations. Did I understood correctly that we don't need to mark the new operation as |
Yes, but the question is if we need a SIP committee approval for all these operation additions, before we can merge this. |
No, historically library additions didn't require SIP approval. |
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.
LGTM
The baseVersion in the main branch is still 3.1.3-RC1, I don't know if it will be bumped before the next release so until this is changed we'd need the |
Why wouldn't it be bumped before? AFAIK, there is no rush on this, so can wait for 3.2.0-RC1. |
Well, we need a reason to bump, that can be because enough experimental changes have accumulated or because there's some big PR that requires a bump and we don't want to keep it open too long, I think that it'd make sense to do it now but it requires someone to take the time to go through experimental changes, etc. |
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.
All symbols that are made not-experimental should be marked with @since("3.2")
annotation.
This is no longer true.
62cf1c6
to
263b4d9
Compare
Blocked on #14866 and its followups. |
Seems that we still cannot use Are these annotations still needed with the new versioning scheme? @Kordyjan Are we sure we want to remove the experimental flags? @soronpo @OlivierBlanvillain I am asking because I am investigating more general ways to represent term applications at the type-level, which would make these types unneeded. For example, if we can represent the type of the result of an addition natively with something like Also, there are still some open questions about the signatures of these types like singletonness and variance: type +[A <: Singleton & Int, B <: Singleton & Int] <: Singleton & Int
type +[+A <: Int, +B <: Int] <: Int
type +[A <: Int, B <: Int] <: Int (I am actually now pretty sure that I should revert #14452 and go with the third option.) Is it a blocker for you to have these types as experimental @soronpo? |
I think the feature is useful and was enough time under
Not a blocker for me. But maybe there are users of the singleton-ops library that it's a blocker for them to migrate to Scala 3.
It would be interesting to see. But this is a language change vs. |
No. My previous comment is now outdated. |
263b4d9
to
dd0bab0
Compare
We discussed this with the compiler team and decided that type-level operations should stay experimental for now, to let us time to evaluate potential alternatives. |
What about the operations that are already non-experimental, should we annotate those as experimental? I would personally advocate for making what we have non-experimental since it's working and already being used, even if that means deprecating things later when we have better alternatives. For context, we've been discussing the possibility of adding a better representation for term-level functions in types since 2018 (#3887). |
Oh, I didn't realize that some type-level operations were already stable. So we re-discussed it and I got the approval for making all operations in this PR non-experimental 🥳 |
Last failing tests seem to be related to a list of experimental APIs that needs to be updated:
|
dd0bab0
to
96a4c1b
Compare
Let's get that merged :) |
If that's OK I'll let someone else pull the trigger because of the release/version implications, which I'm not really on top of :) |
"scala.compiletime.ops.long", "scala.compiletime.ops.long$", | ||
"scala.compiletime.ops.string$.Length", | ||
"scala.compiletime.ops.string$.Matches", | ||
"scala.compiletime.ops.string$.Substring", |
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.
@mbovel didn't we say that these operations would stay experimental?
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.
See #14431 (comment); when we first discussed it, I hadn't realized that some compile-time operations were already stable. Given this, I re-discussed it with Martin and he agreed to make these operations stable as well.
The argument is that operations on long
, float
and double
are exactly the same as the ones on int
which are already stable, so it makes sense to make them stable as well. In term of maintenance, this doesn't change much.
Including operations on strings as well makes sense are they are important building blocks to do anything useful with strings at the type-level (Olivier used them for his work on regular expressions for example).
This PR builds on #13400 to add a type-level
CharAt
operation. It's almost possible to define that function in user space:The only difference being that
Substring
returns aString
, whileCharAt
returns aChar
.@soronpo I've added you as a reviewer, let me know if you have time to have a look!