2 ms·
That's an implementation question, which seems orthogonal to questions of syntax and semantics. As for efficiency, we have decades of experience of compiling p
by twic 7y ago
That's an implementation question, which seems orthogonal to questions of syntax and semantics.
As for efficiency, we have decades of experience of compiling pattern matching, so i would be surprised if it was always just an if-else ladder. The authors of the proposal to add it to Java think that, compared to explicit if-elses, "it is more optimizable too; in this case we are more likely to be able to do the dispatch in O(1) time":
https://openjdk.java.net/jeps/8213076 https://openjdk.java.net/jeps/8213076
I imagine this is through approaches which convert the cases to integers, and then do a traditional jump table etc.