Object.toString, toHash, opCmp, opEquals

Quirin Schroll qs.il.paperinik at gmail.com
Thu Jun 6 08:30:48 UTC 2024


On Friday, 26 April 2024 at 22:55:32 UTC, Jonathan M Davis wrote:
> And given that `Object` really doesn't need to have any of 
> these functions, we likely would have removed them years ago if 
> it weren't for the fact that something like that would break 
> code (in large part due to the `override` keyword; a lot of the 
> code would have worked just fine with those functions being 
> removed from `Object` if the derived classes didn't have to 
> have `override`, which will then become an error when the base 
> class version of the function is removed). Andrei also proposed 
> `ProtoObject` as a way to change the class hierarchy so that we 
> could remove these functions (as well as the monitor) from 
> classes without breaking code built on top of `Object`. So, 
> we've known for years that we could fix this problem if we 
> could just remove these functions from `Object`.

If it’s for the `override` keyword alone, the compiler could 
recognize that a class overrides a formerly present `Object` 
method and issue a deprecation instead of an error while 
pretending these particular uses `override`.


More information about the Digitalmars-d mailing list