Skip to content
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

Restrict syntax of typed patterns #11801

Closed
liufengyun opened this issue Mar 18, 2021 · 1 comment
Closed

Restrict syntax of typed patterns #11801

liufengyun opened this issue Mar 18, 2021 · 1 comment

Comments

@liufengyun
Copy link
Contributor

In Scala 2, a typed pattern is always of the form x: T. Scala 3 changed the syntax to pat: T in #6919 to support syntax like 3956: BigInt.

This feature pat: T is potentially useful as argued by many. However, I'd like to argue that it's better to introduce it later:

As argued by C.A.R. Hoare in The Emperor's Old Clothes [1]:

When any new language design project is nearing completion, there is always a mad rush to get new features added before standardization. The rush is mad indeed, because it leads into a trap from which there is no escape. A feature which is omitted can always be added later, when its design and its implications are well understood. A feature which is included before it is fully understood can never be removed later.

While generalizing to pat: T from x: T might make specification simpler, it makes correct implementation more complex (bug #10994). To quote [1] again:

The price of reliability is the pursuit of the utmost simplicity.

Other context

References

  1. The Emperor's Old Clothes, C.A.R. Hoare, 1981
@liufengyun
Copy link
Contributor Author

We discussed this in the meeting, and it's decided to keep this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant