<?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/"
		>
<channel>
	<title>Comments on: GADTs in C++</title>
	<atom:link href="http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/</link>
	<description>... but that doesn&#039;t matter, because I turn it into a sexy dance</description>
	<lastBuildDate>Tue, 25 Oct 2011 15:04:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: zerop</title>
		<link>http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/comment-page-1/#comment-95</link>
		<dc:creator>zerop</dc:creator>
		<pubDate>Thu, 08 Feb 2007 10:59:29 +0000</pubDate>
		<guid isPermaLink="false">http://ken.friislarsen.net/blog/?p=30#comment-95</guid>
		<description>You could have used references instead of shared pointers, especially since you have immutable classes.

class Plus : public Exp {
public:
  virtual int eval() const {
    return lhs.eval() + rhs.eval();
  }
  explicit Plus(Exp const &amp;lhs_, Exp const &amp;rhs_)
    : lhs(lhs_), rhs(rhs_)
  {}
private:
  const Exp &amp;lhs, &amp;rhs;
};</description>
		<content:encoded><![CDATA[<p>You could have used references instead of shared pointers, especially since you have immutable classes.</p>
<p>class Plus : public Exp {<br />
public:<br />
  virtual int eval() const {<br />
    return lhs.eval() + rhs.eval();<br />
  }<br />
  explicit Plus(Exp const &amp;lhs_, Exp const &amp;rhs_)<br />
    : lhs(lhs_), rhs(rhs_)<br />
  {}<br />
private:<br />
  const Exp &amp;lhs, &rhs;<br />
};</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/comment-page-1/#comment-92</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Sun, 06 Mar 2005 21:13:15 +0000</pubDate>
		<guid isPermaLink="false">http://ken.friislarsen.net/blog/?p=30#comment-92</guid>
		<description>Oh, but I don&#039;t claim to have done anything new with my embedding of the tiny expression language.  And, as you say, somebodyelse have properly done something like this already.  At least the matrix libraries that checks dimentions at compile time must have something similar.  However, what &lt;em&gt;is&lt;/em&gt; new is that Claudio and Andrew present a general and structured way of handling the embedding of the static semantics of a DSEL (at least they present one of the needed pieces).

In fact, I&#039;m not really sure that the presented embedding of the expression language is really useful.  Because often you &lt;em&gt;want&lt;/em&gt; to be able to construct nonsense expressions, for example in a parser.  But that example had the advantage that it was inspired by a publically available example by Peter Sestoft.</description>
		<content:encoded><![CDATA[<p>Oh, but I don&#8217;t claim to have done anything new with my embedding of the tiny expression language.  And, as you say, somebodyelse have properly done something like this already.  At least the matrix libraries that checks dimentions at compile time must have something similar.  However, what <em>is</em> new is that Claudio and Andrew present a general and structured way of handling the embedding of the static semantics of a DSEL (at least they present one of the needed pieces).</p>
<p>In fact, I&#8217;m not really sure that the presented embedding of the expression language is really useful.  Because often you <em>want</em> to be able to construct nonsense expressions, for example in a parser.  But that example had the advantage that it was inspired by a publically available example by Peter Sestoft.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asger Ottar Alstrup</title>
		<link>http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/comment-page-1/#comment-91</link>
		<dc:creator>Asger Ottar Alstrup</dc:creator>
		<pubDate>Sat, 05 Mar 2005 16:46:03 +0000</pubDate>
		<guid isPermaLink="false">http://ken.friislarsen.net/blog/?p=30#comment-91</guid>
		<description>I agree that trying to implement this using the Boost variant is an interesting thought.

But the question on my mind is: Is this really new? I would have thought that one of the numerous expression template systems like

http://exmat.sourceforge.net/
http://research.microsoft.com/projects/greta/
http://www.boost.org/libs/numeric/ublas/doc/index.htm
http://www.oonumerics.org/blitz/
http://acts.nersc.gov/events/PI1999/pete/

etc. etc. would have compile time type safety for expressions already?</description>
		<content:encoded><![CDATA[<p>I agree that trying to implement this using the Boost variant is an interesting thought.</p>
<p>But the question on my mind is: Is this really new? I would have thought that one of the numerous expression template systems like</p>
<p><a href="http://exmat.sourceforge.net/" rel="nofollow">http://exmat.sourceforge.net/</a><br />
<a href="http://research.microsoft.com/projects/greta/" rel="nofollow">http://research.microsoft.com/projects/greta/</a><br />
<a href="http://www.boost.org/libs/numeric/ublas/doc/index.htm" rel="nofollow">http://www.boost.org/libs/numeric/ublas/doc/index.htm</a><br />
<a href="http://www.oonumerics.org/blitz/" rel="nofollow">http://www.oonumerics.org/blitz/</a><br />
<a href="http://acts.nersc.gov/events/PI1999/pete/" rel="nofollow">http://acts.nersc.gov/events/PI1999/pete/</a></p>
<p>etc. etc. would have compile time type safety for expressions already?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/comment-page-1/#comment-94</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Sat, 05 Mar 2005 13:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://ken.friislarsen.net/blog/?p=30#comment-94</guid>
		<description>Yes, I know about the Boost variant library. I think the best way to compare my solution with a varient is to look at the &lt;a href=&quot;http://www.boost.org/doc/html/variant/tutorial.html#variant.tutorial.recursive&quot;&gt;Recursive variant types&lt;/a&gt;. The variant library coresponds roughly to ML and Haskell datatypes in C++. That is, if you remove all the template stuff from my solution then you get more or less the idiom that variant package into a library.  Furthermore, variant makes a different tradeoff with respect to extensability of the datatype and certain forms of type safety at the C++ level (see &lt;a href=&quot;http://ken.friislarsen.net/blog/index.php?p=3&quot;&gt;my entry on the visitor pattern&lt;/a&gt; for a bit more discussion of the tradeoffs).  But the variant example of embedding expressions does not enforce the type-safty of the &lt;em&gt;embedded expressions&lt;/em&gt;.  But I think you could use my technique (which is really Andrew, Claudio, and Peter&#039;s technique) with the variant library.  That would be an interesting experiment. Thus, I think that my technique complements the variant library.

With respect to AST (the language), as you say it is a DSL for generationg AST classes in C++, whereas my solution is a pattern/style/idiom for writting ASTs (or DSELs) manually.  But if you look at the C++ classes generated by AST then they use a different (ugly) idiom.  Also, I don&#039;t think that AST will enforce type-safety of the embedded language. But AST could be changed to generate classes using my technique.

Hope this makes my writing more clear. :-)</description>
		<content:encoded><![CDATA[<p>Yes, I know about the Boost variant library. I think the best way to compare my solution with a varient is to look at the <a href="http://www.boost.org/doc/html/variant/tutorial.html#variant.tutorial.recursive">Recursive variant types</a>. The variant library coresponds roughly to ML and Haskell datatypes in C++. That is, if you remove all the template stuff from my solution then you get more or less the idiom that variant package into a library.  Furthermore, variant makes a different tradeoff with respect to extensability of the datatype and certain forms of type safety at the C++ level (see <a href="http://ken.friislarsen.net/blog/index.php?p=3">my entry on the visitor pattern</a> for a bit more discussion of the tradeoffs).  But the variant example of embedding expressions does not enforce the type-safty of the <em>embedded expressions</em>.  But I think you could use my technique (which is really Andrew, Claudio, and Peter&#8217;s technique) with the variant library.  That would be an interesting experiment. Thus, I think that my technique complements the variant library.</p>
<p>With respect to AST (the language), as you say it is a DSL for generationg AST classes in C++, whereas my solution is a pattern/style/idiom for writting ASTs (or DSELs) manually.  But if you look at the C++ classes generated by AST then they use a different (ugly) idiom.  Also, I don&#8217;t think that AST will enforce type-safety of the embedded language. But AST could be changed to generate classes using my technique.</p>
<p>Hope this makes my writing more clear. <img src='http://ken.friislarsen.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Asger Ottar Alstrup</title>
		<link>http://ken.friislarsen.net/blog/2005/03/03/gadt-in-c/comment-page-1/#comment-93</link>
		<dc:creator>Asger Ottar Alstrup</dc:creator>
		<pubDate>Sat, 05 Mar 2005 10:58:28 +0000</pubDate>
		<guid isPermaLink="false">http://ken.friislarsen.net/blog/?p=30#comment-93</guid>
		<description>Do you know about the Boost variant library?

http://www.boost.org/doc/html/variant.html

How does this compare to your solution?

Also, how does this compare to AST:

http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/ast/index.html

This is a Domain Specific Language which generates ASTs in C++.</description>
		<content:encoded><![CDATA[<p>Do you know about the Boost variant library?</p>
<p><a href="http://www.boost.org/doc/html/variant.html" rel="nofollow">http://www.boost.org/doc/html/variant.html</a></p>
<p>How does this compare to your solution?</p>
<p>Also, how does this compare to AST:</p>
<p><a href="http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/ast/index.html" rel="nofollow">http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/ast/index.html</a></p>
<p>This is a Domain Specific Language which generates ASTs in C++.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

