<?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>The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx</link><description>A reader questions the nature of the value type when he writes, Sender: Slawomir Lisznianski ===================================== 1) Lack of support for SMFs makes value classes unnatural to use. An example in the C++/CLI spec at page 33 is incorrect,</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#195324</link><pubDate>Sun, 25 Jul 2004 03:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:195324</guid><dc:creator>Kevin</dc:creator><description>&amp;lt;Stan Lippman&amp;gt; When you think value class, think integer. Then things will begin to click for you. &amp;lt;/Stan Lippman&amp;gt;&lt;br&gt;&lt;br&gt;Doesn't int provide any copy constructor(s)and overloaded assignment operator? The following code snippet illustrates the contrary side of the story.&lt;br&gt;&lt;br&gt;int a = 2.0; // copy ctor&lt;br&gt;char ch = 'a';&lt;br&gt;a = ch;  // assignment&lt;br&gt;&lt;br&gt;It would be interesting to see how one can implement an int value class that behaves the exactly same way as the built-in int type.</description></item><item><title>re: The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#195645</link><pubDate>Sun, 25 Jul 2004 05:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:195645</guid><dc:creator>stan lippman</dc:creator><description>no -- you're not thinking blitable, and you are not thinking value. you are thinking class, and you will be disappointed with the union ...</description></item><item><title>re: The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#197090</link><pubDate>Mon, 26 Jul 2004 14:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197090</guid><dc:creator>Slawomir Lisznianski</dc:creator><description>May be &amp;quot;value class&amp;quot; should change into &amp;quot;value blitable&amp;quot;? ;-)&lt;br&gt;&lt;br&gt;Well, it looks to me that the originally legitimate idea of introducing a lightweight value class met unanticipated implementation difficulties. Usage constraints were introduced and we ended up with yet another language artifact of limited value. &lt;br&gt;&lt;br&gt;</description></item><item><title>re: The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#197449</link><pubDate>Mon, 26 Jul 2004 20:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197449</guid><dc:creator>stan lippman</dc:creator><description>well, value types are the odd fellow out in all dynamic programming models. &lt;br&gt;&lt;br&gt;i would not agree with your characterization. the `original idea' is the CLI value type -- which is valuable when contrasted with a heap based object. &lt;br&gt;&lt;br&gt;you are looking at it from a C++ perspective, and are dissatisfied that the value class does not have x, y, and z characteristics, which you would expect in a native C++ class.&lt;br&gt;</description></item><item><title>re: The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#197790</link><pubDate>Tue, 27 Jul 2004 01:59:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197790</guid><dc:creator>Nish</dc:creator><description>Hey Stan&lt;br&gt;&lt;br&gt;One really good use to having a default ctor for a value class would be when you had an enum member and you wanted to initialize the enum member to a value other than the first value in the enumeration.&lt;br&gt;&lt;br&gt;Say you have a enum type called Sex and you want to initialize it to female in the default ctor.&lt;br&gt;&lt;br&gt;How do you work around situations like this? Is the solution then, not to use value classes if you want to do initialization of value class members to non-null values?</description></item><item><title>re: The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#197875</link><pubDate>Tue, 27 Jul 2004 05:10:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:197875</guid><dc:creator>stan lippman</dc:creator><description>agreed -- there are instances one can take for a spin in which a default ctor would be useful. &lt;br&gt;&lt;br&gt;in your example, of course, the solution is to let female have an associated value of 0, as in enum class gender { female, male };&lt;br&gt;&lt;br&gt;let me just reiterate that the CLI object model does not support that abstraction. &lt;br&gt;&lt;br&gt;we did add support for (a) deterministic finalization, (b) copy ctor and copy assignment operator, and (c) support for instance operators ... but all for reference types. &lt;br&gt;&lt;br&gt;we haven't been all bad, after all. :-)&lt;br&gt;&lt;br&gt;here is what the design guidelines in the visual studio 2005 beta have to say about value types -- unfortunately, it is written in a C#-centric mindset in which struct serves as a synonym for value type ... hopefully we can fix that before the rtm ...&lt;br&gt;&lt;br&gt;from the beta documentation:&lt;br&gt;&lt;br&gt;It is recommended that you use a struct for types that meet any of the following criteria: &lt;br&gt;&lt;br&gt;Act like primitive types. &lt;br&gt;Have an instance size under 16 bytes. &lt;br&gt;Are immutable. &lt;br&gt;Value semantics are desirable. &lt;br&gt;&lt;br&gt;Do not provide a default constructor for a struct. Note that C# does not allow a struct to have a default constructor. The runtime inserts a constructor that initializes all the values to a zero state. This allows arrays of structs to be created without running the constructor on each instance. Do not make a struct dependent on a constructor being called for each instance. Instances of structs can be created with a zero value without running a constructor. You should also design a struct for a state where all instance data is set to zero, false, or null (as appropriate) to be valid. &lt;br&gt;</description></item><item><title>Feed Search Engine - All Fresh Articles And News Are Here</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#6522974</link><pubDate>Mon, 26 Nov 2007 02:28:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6522974</guid><dc:creator>Feed Search Engine - All Fresh Articles And News Are Here</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://feeds.maxblog.eu/item_1128423.html"&gt;http://feeds.maxblog.eu/item_1128423.html&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>The Value of a Value Class</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#6524885</link><pubDate>Mon, 26 Nov 2007 06:02:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6524885</guid><dc:creator>The Value of a Value Class</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://feeds.maxblog.eu/item_1230810.html"&gt;http://feeds.maxblog.eu/item_1230810.html&lt;/a&gt;&lt;/p&gt;
</description></item><item><title> Stan Lippman s BLog The Value of a Value Class | internet marketing tools</title><link>http://blogs.msdn.com/slippman/archive/2004/07/23/193353.aspx#9758214</link><pubDate>Tue, 16 Jun 2009 07:38:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9758214</guid><dc:creator> Stan Lippman s BLog The Value of a Value Class | internet marketing tools</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://einternetmarketingtools.info/story.php?id=22241"&gt;http://einternetmarketingtools.info/story.php?id=22241&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>