On 21.05.23 11:55, Theo wrote:
class MerchantShip : Ship
{
     private int speed = 0; // If only I had 'private(this)' !!

    // how do I know this method is actually an implementation of an interface method
     // and not a method specific to this class?
    // AND ... how come I can change a @safe interface method into a @trusted one?
     public @trusted void setSpeed(int speed)
     {
         int *s = void; // Mmmm.. and my interface all had @safe methods!!
         this.speed = speed;
     }
[...]
}

As far as I understand, a method that has the right signature is always an implementation of the interface. There is no way to make a method of the same name, with the same parameters, etc. that is "specific to the class".

@trusted means that you're allowed to use @system features in the implementation while the function must follow the restrictions of @safe when called. Since @trusted functions are guaranteed (by the programmer) to be safe, they are allowed to overload/implement @safe functions/prototypes.

If you create an @trusted function that is not safe to call, that's an error on your part.

Reply via email to