From what I've read, I was inclined to think that = was overloaded for Object.Equals in the majority (if not all) cases. Object does a quick reference/memory address check and if two references are the same, Object.Equals deems them equal.. Some types, like String, override this behaviour to implement per-character equivalence checking or something simialr, hence = can be used to determine whether the content of two strings is identical, even if they live at separate areas of memory and are distinct instances.
Where i got really confused, was with Nothing = Nothing being allowed, whereas Nothing.Equals(Nothing) will inherently fail, and I havent so far seen an Object definition for Nothing (that is to say, it doesnt appear to be implemented in the language as an object type) and this notion is persisted into other OO languages.
So it begs the question; is Nothing a type? Or in a similar way to Nullable, can it/is it modified under the skin to be typed in a way we never see?
I'm not sure I understand the initial guess that for = to work, types must be identical - at what level in the hierarchy are we talking about? Pretty much everything in VB is the same type as anything else if taken back to the Object root, and Objects can be compared with =. Similarly, its reasonable to say in an event handler:
If sender = myButton
in this case, are you asserting that it is because the "sender as Object" is actually of type button, that the comparison can succeed? MY initial inkling would be that it is the other way round; thanks to the fact that myButton can be demoted to Object, and Object's = used (in the absence of an overriding Button.Equals).. And I get this thinking from some curiously written event handlers that work like:
If sender = myButton then 'do the button thing
Else If sender = myCheckBox Then 'do the checkbox thing
sender is either a button or a checkbox, but this code wont break.. Which leads me to believe that the myButton/myCheckbox is demoted to Object and a reference equivalence performed..
Which i guess, brings me to "what is Nothing d/promoted to in the case of ?Nothing = Nothing" and is it special in this regard? If effort was made to have this special, why not carry it through and just have If myButton = Nothing Then myButton = New Button()