Discussion Thread: DIP 1042--ProtoObject--Community Review Round 1
Guillaume Piolat
first.last at gmail.com
Fri Jan 14 22:41:45 UTC 2022
On Tuesday, 11 January 2022 at 15:18:00 UTC, Adam D Ruppe wrote:
>
> The reality is the only thing here that would actually require
> a breaking change is removing the monitor.
After speaking a bit with Adam, I discovered the proponents of an
alternative to this DIP.
Let's call us this "covariant camp" (or was it contravariance?).
## Attributes
I sum up the position of the "dual" camp people in an example:
AFAIK the DIP is intended to (say) allows a heterogeneous @nogc
hashmap of ProtoObject, using the new @nogc toHash call.
BUT you can add attributes to a virtual function in derived class
and its children.
HENCE if all your heterogeneous object have a tightened
restriction in toHash in a derived class, just derive all from
that class and it would also works.
Instead of a hashmap of ProtoObject, you would have a hashmap of
HashObject, where HashObject is a derivative of Object with
tightened restrictions.
class HashObject : Object
{
override const @nogc nothrow pure @safe scope size_t
toHash();
}
## Monitor
The alternative then, if Object stays the root class, would be to
depreciate the monitor and remove Object.factory. Eventually
synchronized(obj) can only take SynchronizedObject as parameter.
(Adam further makes the argument that instead of a transition to
ProtoObject to get our 16 bytes back and win the monitor bytes,
it would be an automatic gain.)
(Sorry if I misrepresent point of views here. I myself have no
formed opinion about all this)
More information about the Digitalmars-d
mailing list