RefObject and ValObject

Brian Goetz brian.goetz at
Mon Apr 15 15:35:53 UTC 2019

> For (2) the proposal I saw earlier said something like, we'd like for `new Object` to mean REFERENCE. I think that is a siren song, and this issue has been addressed by Brian's proposal to deal with `new Object` as a migration problem. Rather than suggesting to use some static factory instead (which works for plain instance creation but not for inner class creation) I think perhaps the user code should be migrated to use `new RefObject` and `new RefObject() { }` instead (at least if people want the reference semantics). But these are minor details

What I like about treating this as a migration problem is, that despite the inconvenience, the resulting code is actually _a lot more clear_.  The first time I saw “new Object()” (that was a long time ago), I remember thinking “What the heck is the point of that?”, until I realized that Objects had a secret object identity.  Whereas “new IdentityObject()” is more clear that you are creating an instance _for the precise purpose of using its identity_.  

So, while there is some migration pain, the resulting language is actually more clear.  I like that.

More information about the valhalla-spec-observers mailing list