Hacker News new | ask | show | jobs
by WalterBright 10 days ago
There's one more aspect to it in D:

    struct S {
      int a;
      int f(); //getter
      void f(int i); // setter
    }
    void test() {
      S s;
      int i = s.a;
      int j = s.f;
      s.f = i;

      S* ps;
      int k = ps.a;
      int l = ps.f;
      ps.f = k;
    }
i.e. the field can be replaced by a function and the usage of it would not change.
1 comments

Actually, those are things I like about C:

- It does not run code behind my back when I access a field.

- I see when a pointer is used, so the syntactic distinction between -> and . is important.

Being able to change this without changing these little things is far less important to me than being able to understand important properties of the code just by looking at it.