[Mono-dev] Template and assignment operator in C#

Rusmin Susanto rusminsusanto at yahoo.com
Thu Apr 27 20:20:13 EDT 2006

Hi all. I have some questions.
  1. Is there any trick in C# similar to Expression Template in C++ to avoid pairwise evaluation? 
For example, if we have the following code in C++:
   // DoubleVec is a class that contains a vector of double. This class has typical aritmathic operator, + - * /.
        DoubleVec y(1000), a(1000), b(1000), c(1000),d(1000); 
        y = (a+b)/(c-d);
  without expression template we will need 4 loops and 3 temporaries DoubleVect to process the expression as the operands are processed 2 at a time. With expression template trick in C++, we can process the expression in one hit (in one loop, no temporaries).
  2. Is template processed at compile time or run time in C#? I know that in C++ it's processed at compile time.
  3. I know that in C# the assignment operator '=' for object will copy the reference of rhs to the lhs.
How about if we need to define an assignment operator for an object that needs to copy the value of member variables (not reference) of rhs to lhs?
How do we tell C# to copy value, not reference?
  Many thanks for your attention.

Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1¢/min.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060427/5af5d356/attachment.html 

More information about the Mono-devel-list mailing list