|
|
|
|
|
by jhck
5779 days ago
|
|
So it was easy to check that you couldn't add a int to a strongly typed list of strings, but only in source. (I think, I'm not as well read as javac / JVM internals) You're right. Here's Jim Waldo's explanation from Java: The Good Parts: "the inability to change the VM or bytecodes [due to requirements of backwards compatibility] meant that parameterized types could occur only in the source code. The type system of the runtime hasn’t changed, and doesn’t include generics or parameterized types. What we see in our code as a Set<Player> is seen in the bytecodes as simply a Set of objects." |
|
But this got me thinking about compiler tricks in general, and how they can be a good thing.
For instance in C# the keywords foreach, and using are just compiler tricks, as well as the notion of closures.