Re:The Unsound Playground: Java and Scala's Type Systems are...
by RHSeeger on Sunday November 27, 2016 @08:40PM
(#13052841)
You could define what an array accepts vs returns separately (input vs output). Admittedly, you're pretty much into generics (good ones, not what Java has) at that point.
Edit: Could use a better word for "good" that sounds less dismissive, but I couldn't think of one. Java's generics are lacking in certain areas, unfortunately.
Re:The Unsound Playground: Java and Scala's Type Systems are...
by MrBuddyCasino on Monday November 28, 2016 @04:09AM
(#13054283)
Generics in Java are pretty complicated already, so much so that very few developers fully understand them. I'm not sure the gain in complexity would be worth the added safety.
I'd like to see examples in languages where this is possible, if there are any?
You could force every array-function-caller to cast their args to e.g. `Object[]`, but that seems like it'd require more work for even less safety. Though I'd love a read-only concept in Java, for read purposes :|
[1]: I think. If I'm wrong, someone please correct me!