<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Writing functional code in C++ IV &#8211; Algebraic datatypes</title>
	<atom:link href="http://lucabolognese.wordpress.com/2012/04/27/writing-functional-code-in-c-iv-algebraic-datatypes/feed/" rel="self" type="application/rss+xml" />
	<link>http://lucabolognese.wordpress.com/2012/04/27/writing-functional-code-in-c-iv-algebraic-datatypes/</link>
	<description>x += x++;</description>
	<lastBuildDate>Fri, 03 May 2013 18:26:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: lucabol</title>
		<link>http://lucabolognese.wordpress.com/2012/04/27/writing-functional-code-in-c-iv-algebraic-datatypes/#comment-229</link>
		<dc:creator><![CDATA[lucabol]]></dc:creator>
		<pubDate>Mon, 23 Jul 2012 17:25:46 +0000</pubDate>
		<guid isPermaLink="false">https://lucabolognese.wordpress.com/?p=92#comment-229</guid>
		<description><![CDATA[Hi Clement,
Yes, you can simulate algebraic datatypes with inheritance and type testing, albeit more verbosely and less efficiently. The if(true) thing is just a bug. Probably at some point in the coding the condition was a bit more interesting.]]></description>
		<content:encoded><![CDATA[<p>Hi Clement,<br />
Yes, you can simulate algebraic datatypes with inheritance and type testing, albeit more verbosely and less efficiently. The if(true) thing is just a bug. Probably at some point in the coding the condition was a bit more interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clément</title>
		<link>http://lucabolognese.wordpress.com/2012/04/27/writing-functional-code-in-c-iv-algebraic-datatypes/#comment-228</link>
		<dc:creator><![CDATA[Clément]]></dc:creator>
		<pubDate>Sat, 21 Jul 2012 11:30:47 +0000</pubDate>
		<guid isPermaLink="false">https://lucabolognese.wordpress.com/?p=92#comment-228</guid>
		<description><![CDATA[I&#039;ve developped this idea on my own blog, &lt;a href=&quot;http://pit-claudel.fr/clement/blog/using-abstract-classes-to-simulate-tagged-unions-aka-sum-types/&quot; rel=&quot;nofollow&quot;&gt;http://pit-claudel.fr/clement/blog/using-abstract-classes-to-simulate-tagged-unions-aka-sum-types/&lt;/a&gt;]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve developped this idea on my own blog, <a href="http://pit-claudel.fr/clement/blog/using-abstract-classes-to-simulate-tagged-unions-aka-sum-types/" rel="nofollow">http://pit-claudel.fr/clement/blog/using-abstract-classes-to-simulate-tagged-unions-aka-sum-types/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clément</title>
		<link>http://lucabolognese.wordpress.com/2012/04/27/writing-functional-code-in-c-iv-algebraic-datatypes/#comment-227</link>
		<dc:creator><![CDATA[Clément]]></dc:creator>
		<pubDate>Sat, 21 Jul 2012 11:27:20 +0000</pubDate>
		<guid isPermaLink="false">https://lucabolognese.wordpress.com/?p=92#comment-227</guid>
		<description><![CDATA[Amusing solution! I&#039;d like to expend on the first few lines of your article though:
  &quot;Very roughly, where object orientation uses derivation, functional programming uses algebraic datatypes. &quot;

Expanding on this, you could implement your &lt;code&gt;LivinEntity&lt;/code&gt; type like this:
&lt;code&gt;
#include 

using namespace std;

class LivingEntity {
    public:
        string name;
        virtual void print() = 0;

        LivingEntity(string name) {
            this-&gt;name = name;
        }

        class Person;
        class Dog;
};

class LivingEntity::Person : LivingEntity {
    public:
        Person(string name) : LivingEntity(name) {}

        void print() {
            cout &lt;&lt; &quot;I am a per named &quot; &lt;&lt; name &lt;&lt; endl;
        }
};

class LivingEntity::Dog : LivingEntity {
    public:
        Dog(string name) : LivingEntity(name) {}

        void print() {
            cout &lt;&lt; &quot;I am a dog named &quot; &lt;&lt; name &lt;&lt; endl;
        }
};


int main()
{
    LivingEntity::Dog a_dog = LivingEntity::Dog(&quot;a dog&quot;);
    LivingEntity::Person a_person = LivingEntity::Person(&quot;a person&quot;);
    a_dog.print();
    a_person.print();
    return 0;
}
&lt;/code&gt;

Also, why do you use &lt;code&gt;else if(true) { __VA_ARGS__}&lt;/code&gt; instead of just &lt;code&gt;else { __VA_ARGS__}&lt;/code&gt; in your macros?

Thanks for the nice article!]]></description>
		<content:encoded><![CDATA[<p>Amusing solution! I&#8217;d like to expend on the first few lines of your article though:<br />
  &#8220;Very roughly, where object orientation uses derivation, functional programming uses algebraic datatypes. &#8221;</p>
<p>Expanding on this, you could implement your <code>LivinEntity</code> type like this:<br />
<code><br />
#include </p>
<p>using namespace std;</p>
<p>class LivingEntity {<br />
    public:<br />
        string name;<br />
        virtual void print() = 0;</p>
<p>        LivingEntity(string name) {<br />
            this-&gt;name = name;<br />
        }</p>
<p>        class Person;<br />
        class Dog;<br />
};</p>
<p>class LivingEntity::Person : LivingEntity {<br />
    public:<br />
        Person(string name) : LivingEntity(name) {}</p>
<p>        void print() {<br />
            cout &lt;&lt; &quot;I am a per named &quot; &lt;&lt; name &lt;&lt; endl;<br />
        }<br />
};</p>
<p>class LivingEntity::Dog : LivingEntity {<br />
    public:<br />
        Dog(string name) : LivingEntity(name) {}</p>
<p>        void print() {<br />
            cout &lt;&lt; &quot;I am a dog named &quot; &lt;&lt; name &lt;&lt; endl;<br />
        }<br />
};</p>
<p>int main()<br />
{<br />
    LivingEntity::Dog a_dog = LivingEntity::Dog(&quot;a dog&quot;);<br />
    LivingEntity::Person a_person = LivingEntity::Person(&quot;a person&quot;);<br />
    a_dog.print();<br />
    a_person.print();<br />
    return 0;<br />
}<br />
</code></p>
<p>Also, why do you use <code>else if(true) { __VA_ARGS__}</code> instead of just <code>else { __VA_ARGS__}</code> in your macros?</p>
<p>Thanks for the nice article!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
