On Sunday, 21 May 2023 at 10:33:07 UTC, ag0aep6g wrote:
On 21.05.23 12:28, ag0aep6g wrote:
Since @trusted functions are guaranteed (by the programmer) to be safe, they are allowed to overload/implement @safe functions/prototypes.


oh ok. so i can override a @safe interface method with a @trusted implementation of that method, and nobody will ever know. I'm not sure how i feel about that.

Likely I would never put @safe in the interface anyway, but even so...

As for the other part, if I use an abstract base class, I *must* indicate when i'm overriding the base class method by explicately saying 'override'.

Would be nice to have something for an interface method, so when it's being implemented, you know that method is the implementation of an interface method, and not just some method specific to that class - see my idea below.

interface Ship
    void setSpeed(int speed);
    int getSpeed();

class PirateShip : Ship
    private int speed = 0; // Here, I really mean 'private(this)'

    public void setSpeed(int speed) : implements Ship
        this.speed = speed;

    public int getSpeed() : implements Ship
        return speed;

// other ships.....

Reply via email to