On Monday, 2 March 2015 at 00:06:52 UTC, deadalnix wrote:
On Sunday, 1 March 2015 at 23:56:02 UTC, Zach the Mystic wrote:
On Sunday, 1 March 2015 at 14:40:54 UTC, Marc Schütz wrote:
I don't think a callee-based solution can work:

  class T {
      void doSomething() scope;
  }
  struct S {
      RC!T t;
  }
  void main() {
      auto s = S(RC!T()); // `s.t`'s refcount is 1
      T t = s.t;          // borrowing from the RC wrapper
      foo(s);
      t.doSomething();    // oops, `t` is gone
  }
  void foo(ref S s) {
      s.t = RC!T();       // drops the old `s.t`
  }

I thought of this, and I disagree. The very fact of assigning to `T t` adds the reference count you need to keep `s.t` from disintegrating. As soon as you borrow, you increment the count.

I'm sure many inc/dec can still be removed.

Do you agree or disagree with what I said? I can't tell.

Reply via email to