Say I have a class hierarchy like this:
  class Base { }
  class Derived : Base { }
A Derived object cannot be referenced as a Base object, but as a const(Base) object. That makes sense to me.

One can replace Base by a @system delegate type (SysDG) and Derived by a @safe delegate type (SafeDG) and it works the same way: a SafeDG object cannot be referenced as a SysDG object, but as a const(SysDG) object.

However, if I try that with function pointers instead of delegates (SysFP, SafeFP), for some reason, a SafeFP cannot be referenced as a const(SysFP). This makes no sense in my head. Is there some reason I'm unable to see?

Example code is here: https://run.dlang.io/is/zSNArx

Reply via email to