On Apr 29, 2008, at 5:55 PM, Luigi Ballabio wrote:
> On Mon, 2008-04-21 at 08:19 -0700, snovik wrote:
>> I am on the team to port ql to c# .net and trying to understand the
>> reasons
>> behind Disposable<T> class. It looks to me like a tricky memory-saving
>> excercise and I wonder if it really is or there are other reasons.
>
> It's not for saving memory---it's for performance. C++ has pass-by-copy
> semantics.
Also, the same applies to assignment. In C++, when we write
a = b;
you don't end up with two references (a and b) referring to the same
instance. You end up with a being a new copy of b.
Luigi
P.S. I almost forgot---good luck with your C# port...
|