Michel Fortin Wrote: > On 2009-10-13 11:39:21 -0400, Sean Kelly <[email protected]> said: > > > I disagree about poor performance though. With unique references or > > move semantics, a copy of even complex data isn't necessary to ensure > > that a message is passed safely. > > Yeah, but for unique reference to be usable you need lent semantics, > otherwise you can't make sure you're the unique holder once you call a > function to do something with your unique object. > > Anything that use the reference could be storing it elsewhere: > > unique!Object o = new Object; > o.doSomething(); > > How in the example above can I enforce that doSomething() won't escape > the 'o' reference elsewhere? 'doSomething' could be made 'pure', but > that trick will only work for one-argument functions (in the case > above, the argument is the implicit 'this') because otherwise a pure > function could leak the reference through another argument.
I honestly don't know how to enforce this-- I simply mentioned it because people have suggested it. Phobos already has assumeUnique() for converting to invariant, which is one option. I was hoping someone could suggest alternatives.
