-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Clause Interleaving to method definitions (#14019)
This aims to add the ability to declare functions with many clauses of type parameters, instead of at most one, and to allow those clauses to be interleaved with term clauses: ```scala def foo[A](x: A)[B](y: B) = (x, y) ``` All user-facing details can be found in the [Scala 3 new features doc](https://github.com/lampepfl/dotty/blob/2a079f92bfc05420e90987d908c41589ac94418d/docs/_docs/reference/other-new-features/generalized-method-syntax.md), and in the [SIP proposal](scala/improvement-proposals#47) The implementation details are described below in the commit messages The community's opinion of the feature can be found on [the scala contributors forum](https://contributors.scala-lang.org/t/clause-interweaving-allowing-def-f-t-x-t-u-y-u) (note however that the description there is somewhat outdated) ### Dependencies This feature has been [accepted by the SIP committee for implementation](scala/improvement-proposals#47 (comment)), it can therefore become part of the language as an experimental feature at any time. The feature will be available with `import scala.language.experimental.clauseInterleaving` ### How to make non-experimental `git revert` the commits named "Make clause interleaving experimental" and "Add import to tests" ### Future Work 1. Implement given aliases with clause interweaving: (to have types depends on terms) ```scala given myGiven[T](using x: T)[U](using y: U) = (x, y) ``` 2. Add interleaved clauses to the left-hand side of extension methods: ```scala extension (using Int)[A](using A)(a: A)[B](using B) def foo: (A, B) = ??? ``` 3. Investigate usefulness/details of clause interweaving for classes and type currying for types: ```scala class Foo[A](a: A)[B](b: B) new Foo(0)("Hello!") // type: Foo[Int][String] ? type Bar[A][B] = Map[A, B] Bar[Char] // should this mean [B] =>> Bar[Char][B] ? ``` (Started as a semester project with supervision from @smarter, now part of my missions as an intern at the scala center)
- Loading branch information
Showing
45 changed files
with
942 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.