Hello Scala community!
This thread is the SIP Committee’s request for comments on a proposal to allow instance creation without using
Summary of the proposal
In short, the proposal is to allow e.g.:
class C(x: String) C("foo") // same as `new C("foo")`
Creator applications generalize a functionality provided so far only for case classes, but the mechanism how this is achieved is different. Instead of generating an
apply method, the compiler adds a new possible interpretation to a function call
new hides an implementation detail, makes code more pleasant to read, and improves consistency between case classes and ordinary classes.
For more details of the proposal, see the documentation page on the Dotty site:
In informal discussions so far, the committee has been more supportive than not, but there has also been some skepticism (from e.g. Seb and Seth). See the following minutes for details:
- “SIP Meeting Minutes: March 11 2020”
Other relevant resources and past discussions in this area include:
- “Further enhance
newsyntax to reduce boilerplate”
(Dotty issue, opened November 2018)
newfrom scala 3”
Expunging `new` from scala 3
(discussion, February 2019)
- “Implement creator applications”
(implementation, merged March 2019)
Perhaps I’ve missed some; if you know of any, please reply with links.
- Is the proposal clear and detailed enough?
- Should this proposal be accepted by the committee for Scala 3?
- Should the proposal be modified before acceptance?
This topic will remain open for at least one month, to allow sufficient time to gather feedback.
As with all SIP threads, please try to keep the thread on-topic and of reasonable length. If a sub-discussion is becoming extensive, it may be best to move it to a separate topic, and then summarize that discussion here with a link, for those interested.