I made a little program to illustrate my confusion :

  import std.stdio;

  class _1 {
          int i;
        
          this(int n) {
                  i = n;
          }
  }

  class _2 {
          _1 instance;
        
          alias twelve = instance.i;
        
          this() {
                  instance = new _1(12);
          }
  }

  void main() {
          _2 two = new _2();
          writeln(two.instance.i);
          writeln(two.twelve);
  }

What i tried to do is create an alias in class _2 of a variable in class _1.
What i would like is :
  two.twelve
to extends to:
  two.instance.i
But the compiler complains it cannot find "this" :
  Error: need 'this' for 'i' of type 'int'

Any ideas?

Reply via email to