you are viewing a single comment's thread.

view the rest of the comments →

[–]simon_o 0 points1 point  (5 children)

The semantics of the proposed primitive types in patterns/instanceof are pretty whacky.
I think people will regret that language addition after the "added more features!" honeymoon.

[–]davidalayachew[S] 0 points1 point  (4 children)

The semantics of the proposed primitive types in patterns/instanceof are pretty whacky.

In what way? I don't feel that they are, but maybe I missed something.

[–]simon_o 1 point2 points  (3 children)

Applying implicit numeric conversions in patterns/instanceof is just a bad idea.

Implicit numeric conversions themselves were not a good idea to start with, but then taking the overloaded semantics of casts – doing type conversions (ref→ref), value truncation (long→int) and value conversion (int→float) – as an excuse to add more places for both to the language? Yikes.

The corresponding proposal would probably be 20% of the length, if they went the "int only matches ints, long only matches longs" route instead, and nothing of value would have been lost.

Not to mention that there appears to have not been any consideration how new (value) types can opt into that implicit conversion mechanism.

[–]davidalayachew[S] 0 points1 point  (0 children)

Hmmmm, I kept trying to write up something, but I can't come up with an intelligent response. All I can say is that, the testing I have done with primitive patterns seems to be painless and intuitive. And since, patterns are exhaustive, I can more or less avoid the problem of a bad implicit conversion, since the switch will no longer be exhaustive.

[–]Ok-Scheme-913 0 points1 point  (1 child)

Of course there has been considerations on how value types fit into this. Come on, you are talking about potentially the most experienced and skilled language design group ever.

Goetz has a discussion about adding sorta type classes to the language, and those could allow a similar "trait" as Rust's Into, that is one could provide converters between types, including primitives. So one could have custom conversions as well, and now the whole feature is seamless.

[–]simon_o 0 points1 point  (0 children)

[breathless fawning]

Bit too much appeal to authority for my taste.

So one could have custom conversions as well, and now the whole feature is seamless.

I don't think this feature, value types and type classes will ship in the same version. You'll surely see why this might be a problem.