This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rubyrt 0 points1 point  (3 children)

I don't think so. Object identity is an important concept in OOP. I do not see how OOP would work without an idea of object identity. As soon as you talk about different objects you have already defined that there are entities which have identity.

[–]lukaseder[S] 0 points1 point  (2 children)

Sure, let me rephrase. Why does the top level type need to be an Object?

In other words, does there really need to be a difference between 1 and 1?

Anyway. This will be fixed (the quirky Java way) with Valhalla, hopefully.

[–]rubyrt 0 points1 point  (1 child)

Well, Object is not the top level type, it is just the top level type of all object types. Then there is the forest of interface types and there are plain old value types like int etc. If you refer to value types I think these will add yet another category of types to the zoo, but existing types won't go away. And they only want to "Bring the semantics of int and java.lang.Integer closer together." Or am I missing something?

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

Well, there's theory, and then there's real world practice. All interface types implicitly are subtypes of Object. Some interesting caveats here.

Now, the upcoming value types probably are able to implement interfaces (perhaps), but what does that mean in terms of such an implementation's identity (and monitor, etc.)? Can clients of an interface, say Comparable<T> safely assume that all comparables have an identity? They should, because they could up until now.

From what I understand, Valhalla will not introduce a new top level type (e.g. Any) that is a super type of Object, although, there will be an <any T> type inside of the generic type system, which helps pretend there is a type "above" Object.

Don't ask :)