On Sunday, 13 May 2018 at 01:52:20 UTC, KingJoffrey wrote:
On Saturday, 12 May 2018 at 18:36:59 UTC, Walter Bright wrote:
On 5/12/2018 9:42 AM, Mike Parker wrote:
Thank goodness we don't have to do this silliness.

[...]
================================
module test;

import std.stdio : writeln;

void main()
{
    Person p = new Person("King Joffrey");

writeln(p.getName); // I designed my class to present this interface. writeln(p._name); // The module couldn't care less about your interface.

p._name = "King Walter"; // even worse, the module can de-throne the king!!
    writeln(p._name);
}

class Person
{
    private string _name;

    public void setName(string name)
    {
        this._name = name;
    }

    public string getName()
    {
        return ProperName(this._name);
    }

    public this(string name)
    {
        _name = name;
    }

    private static string ProperName(string name)
    {
        return name ~ " : The one true king!";
    }
}

===========================================

Again, all you have to do is put class Person in a separate module. Its not that hard. Why is main in the same module if it isn't logically related to Person? It should be in its own module. Its uses Person. main does not extend person, it needs only the public bits. So it goes in its own module. And please, if this bothers you so much, start a new thread. You're spamming someone else's feature request by going off topic.

Reply via email to