ProtoObject and comparison for equality and ordering
Adam D. Ruppe
destructionator at gmail.com
Wed May 15 12:40:46 UTC 2019
On Wednesday, 15 May 2019 at 06:19:19 UTC, Jonathan M Davis wrote:
> Even an interface is a problem, because then that locks in the
> attributes.
That's not completely true in general, and only sort of true in
this specific situation.
In general, attributes are semi-locked, accordance to the Liskov
substitution principle: you can tighten constraints, but not
loosen them on child classes.
(Like with current Object, which has no attributes, you are
allowed to define a child class with `override @nogc @safe
nothrow` etc. But once you do that, you can never remove them in
child classes, since then you'd be breaking the promise of the
parent class' interface)
In this specific situation, the attributes are only locked in
after you define them - which is the same if you did it with or
without the interface. The interface itself does not demand
anything unless it specifically lists them.
But, note, they also are not inferred.
> By templatizing all of the relevant code in druntime
There should be NO code in druntime! All `a < b` is is syntax
sugar for a method call. It does not need and should not use any
other function. Just let the compiler rewrite the syntax to the
call and then do its thing.
The ProtoObject version of __cmp should simply not exist.
More information about the Digitalmars-d
mailing list