You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
In Scala 2, a typed pattern is always of the form
x: T
. Scala 3 changed the syntax topat: T
in #6919 to support syntax like3956: 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:isInstanceOf
checksAs argued by C.A.R. Hoare in The Emperor's Old Clothes [1]:
While generalizing to
pat: T
fromx: T
might make specification simpler, it makes correct implementation more complex (bug #10994). To quote [1] again:Other context
x: T
._*
topat: _*
happend in Use p* for vararg splices #11240. It causes problem (Pattern sequence 'Pattern2*' is allowed by grammar, but behaves strange #11457) and gets reverted in Vararg patterns must be variable patterns or wildcards #11508.References
The text was updated successfully, but these errors were encountered: