Discussion Thread: DIP 1042--ProtoObject--Community Review Round 1

Dom DiSc dominikus at scherkl.de
Fri Jan 14 01:48:06 UTC 2022

On Thursday, 13 January 2022 at 00:59:49 UTC, Mike Parker wrote:
> On Wed, Jan 12, 2022 at 08:26:17PM +0000, Dom DiSc via 
> Digitalmars-d wrote:
> [...]
>> By far the most classes will contain non-comparable values, 
>> because
>> there is only a few "completely ordered" things out there, and 
>> most of
>> them like simple numbers are already implemented.
> This makes me question the wisdom of putting opCmp in the 
> common base of
> all classes.  If only a small subset of classes will be 
> comparable with
> each other

This is a misunderstanding.
First of all, you don't compare classes, but objects (instances) 
of the same class.
And the majority of objects may well be comparable.
My argument was: Nearly every class will contain _some_ (most 
times even only very few) objects that can not be compared to 
others. This means: The class is not completely ordered, but 
still partially ordered. And we need a value to express this 
And comparison is very important in most classes, even if they 
are only partially ordered, so having a common interface for that 
(and I mean: _identical_ in every class, so e.g. always returning 
the same type, namely the 4 float-values -1, 0, 1 and NaN) is 
very important.

More information about the Digitalmars-d mailing list