<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx</link><description>For the work I&amp;#8217;ve been engaged in currently in machine translation of the original language design [thing1] to the revised design of the language [thing2], I have been variously making stabs at understanding the possible usages of a managed Value</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title> Stan Lippman s BLog Value Type Representation Between the Original | internet marketing tools</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#9758448</link><pubDate>Tue, 16 Jun 2009 07:54:46 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9758448</guid><dc:creator> Stan Lippman s BLog Value Type Representation Between the Original | internet marketing tools</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://einternetmarketingtools.info/story.php?id=22318"&gt;http://einternetmarketingtools.info/story.php?id=22318&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9758448" width="1" height="1"&gt;</description></item><item><title> Stan Lippman s BLog Value Type Representation Between the Original | Outdoor Decor</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#9746335</link><pubDate>Sun, 14 Jun 2009 01:06:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9746335</guid><dc:creator> Stan Lippman s BLog Value Type Representation Between the Original | Outdoor Decor</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://outdoordecoration.info/story.php?id=3261"&gt;http://outdoordecoration.info/story.php?id=3261&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9746335" width="1" height="1"&gt;</description></item><item><title> Stan Lippman s BLog Value Type Representation Between the Original |  Portable Greenhouse</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#9690141</link><pubDate>Wed, 03 Jun 2009 11:17:11 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9690141</guid><dc:creator> Stan Lippman s BLog Value Type Representation Between the Original |  Portable Greenhouse</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://portablegreenhousesite.info/story.php?id=32875"&gt;http://portablegreenhousesite.info/story.php?id=32875&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9690141" width="1" height="1"&gt;</description></item><item><title> Stan Lippman s BLog Value Type Representation Between the Original | Outdoor Ceiling Fans</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#9667813</link><pubDate>Sun, 31 May 2009 11:06:07 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9667813</guid><dc:creator> Stan Lippman s BLog Value Type Representation Between the Original | Outdoor Ceiling Fans</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://outdoorceilingfansite.info/story.php?id=3212"&gt;http://outdoorceilingfansite.info/story.php?id=3212&lt;/a&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9667813" width="1" height="1"&gt;</description></item><item><title>re: Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#80744</link><pubDate>Thu, 26 Feb 2004 23:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:80744</guid><dc:creator>Wesner Moise</dc:creator><description>Feel free to delete my prior comments, if I had read more carefully your post, I would have not been confused.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=80744" width="1" height="1"&gt;</description></item><item><title>re: Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#80739</link><pubDate>Thu, 26 Feb 2004 23:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:80739</guid><dc:creator>Wesner Moise</dc:creator><description>I guess the clarification I need from this post was that ToString() must be overridden, for boxing to be avoid.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=80739" width="1" height="1"&gt;</description></item><item><title>re: Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#80733</link><pubDate>Thu, 26 Feb 2004 23:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:80733</guid><dc:creator>Wesner Moise</dc:creator><description>Of course, Complex is boxed in your example, because it is invoking System.ValueType::ToString. System.ValueType is a reference type!!&lt;br&gt;&lt;br&gt;If you provide an overridden implementation of Complex.ToString. It will not be boxed.&lt;br&gt;&lt;br&gt;The IL I get is the following:&lt;br&gt;L_0016: ldc.r8 1&lt;br&gt;L_001f: ldc.r8 2&lt;br&gt;L_0028: call Complex..ctor&lt;br&gt;L_002d: ldloca.s V_4&lt;br&gt;L_002f: call Complex.ToString&lt;br&gt;L_0034: stloc.3 &lt;br&gt;&lt;br&gt;Similarly, for primitive types, no boxing occurs with overridden calls to GetHashCode or ToString().&lt;br&gt;&lt;br&gt;int i=2;&lt;br&gt;int k=3;&lt;br&gt;int j = i.GetHashCode();&lt;br&gt;string str = k.ToString();&lt;br&gt;&lt;br&gt;L_0000: ldc.i4.2 &lt;br&gt;L_0001: stloc.0 &lt;br&gt;L_0002: ldc.i4.3 &lt;br&gt;L_0003: stloc.1 &lt;br&gt;L_0004: ldloca.s V_0&lt;br&gt;L_0006: call int.GetHashCode&lt;br&gt;L_000b: stloc.2 &lt;br&gt;L_000c: ldloca.s V_1&lt;br&gt;L_000e: call int.ToString&lt;br&gt;L_0013: stloc.3 &lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=80733" width="1" height="1"&gt;</description></item><item><title>re: Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#80731</link><pubDate>Thu, 26 Feb 2004 23:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:80731</guid><dc:creator>Yves Dolce</dc:creator><description>Add&lt;br&gt;&lt;br&gt;public override String ToString() { return String.Format( &amp;quot;{0} + {1} i&amp;quot;, r.ToString(), i.ToString() ) ; }&lt;br&gt;&lt;br&gt;to the struct and the boxing is gone:&lt;br&gt;&lt;br&gt;IL_000d:  ldloca.s   c&lt;br&gt;IL_000f:  ldc.r8     1.&lt;br&gt;IL_0018:  ldc.r8     2.&lt;br&gt;IL_0021:  call       instance void NeedToBox.Complex::.ctor(float64, float64)&lt;br&gt;IL_0026:  ldloca.s   c&lt;br&gt;IL_0028:  call       instance string NeedToBox.Complex::ToString()&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=80731" width="1" height="1"&gt;</description></item><item><title>re: Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#80718</link><pubDate>Thu, 26 Feb 2004 22:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:80718</guid><dc:creator>Yves Dolce</dc:creator><description>I just tried with C#:&lt;br&gt;struct Complex&lt;br&gt;{&lt;br&gt;   public Complex( double r, double i )&lt;br&gt;   {&lt;br&gt;      this.r = r ;&lt;br&gt;      this.i = i ;&lt;br&gt;   }&lt;br&gt;   private double r, i ;&lt;br&gt;}&lt;br&gt;&lt;br&gt;...&lt;br&gt;&lt;br&gt;   Complex c = new Complex( 1, 2 ) ;&lt;br&gt;   c.ToString() ;&lt;br&gt;&lt;br&gt;And the IL shows c IS boxed:&lt;br&gt;&lt;br&gt;IL_000d:  ldloca.s   c&lt;br&gt;IL_000f:  ldc.r8     1.&lt;br&gt;IL_0018:  ldc.r8     2.&lt;br&gt;IL_0021:  call       instance void NeedToBox.Complex::.ctor(float64, float64)&lt;br&gt;IL_0026:  ldloc.0&lt;br&gt;IL_0027:  box        NeedToBox.Complex&lt;br&gt;IL_002c:  callvirt   instance string [mscorlib]System.ValueType::ToString()&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=80718" width="1" height="1"&gt;</description></item><item><title>re: Value Type Representation Between the Original and Revised C++</title><link>http://blogs.msdn.com/b/slippman/archive/2004/02/26/80505.aspx#80711</link><pubDate>Thu, 26 Feb 2004 22:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:80711</guid><dc:creator>Yves Dolce</dc:creator><description>Wesner,&lt;br&gt;&lt;br&gt;Try calling ToString() on an instance of:&lt;br&gt;&lt;br&gt;_value class Complex&lt;br&gt;{&lt;br&gt;   public:&lt;br&gt;      Complex( double r, double i ) : m_r(r), m_i(i) {}&lt;br&gt;&lt;br&gt;&lt;br&gt;   public: &lt;br&gt;      //virtual String * ToString() { return String::Format( S&amp;quot;{0} + {1} i&amp;quot;, m_r.ToString(), m_i.ToString() ) ; }&lt;br&gt;&lt;br&gt;   private:&lt;br&gt;      double m_r, &lt;br&gt;             m_i ;&lt;br&gt;} ;&lt;br&gt;&lt;br&gt;I will fail with:&lt;br&gt;error C3610: 'Complex': value type must be 'boxed' before method 'ToString' can be called&lt;br&gt;&lt;br&gt;Uncomment the overriden ToString method or use the __box operator and it works.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=80711" width="1" height="1"&gt;</description></item></channel></rss>