<?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 for TURBU Tech</title>
	<atom:link href="http://tech.turbu-rpg.com/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://tech.turbu-rpg.com</link>
	<description>My thoughts on Delphi programming in general, and particularly on the technical aspects of developing the TURBU engine and editor.</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:51:51 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on How to break the D2010 compiler by Moritz Beutel</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-167</link>
		<dc:creator>Moritz Beutel</dc:creator>
		<pubDate>Thu, 11 Mar 2010 15:51:51 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-167</guid>
		<description>Depends how you recurse. You can easily do that in a loop:

while ((currentType = getSubType(currentType)) != 0)
  allocateSymbolTableEntry (currentType);

As I said, a similar construct compiles fine when using C# or C++. I suspect it works in C# because generics are instantiated at runtime by the CLR, whereas the Delphi compiler has to resolve every instantiation during compile time. In C++ it works because the compiler doesn&#039;t need more than a forward declaration for a certain type in order to use pointers to that type, so it doesn&#039;t attempt to actually instantiate the template.

It should be possible to fix without the Halting problem getting in the way - I guess you would just check whether an instantiation of TFoo&lt;SomethingElse&lt;T, ...&gt;, ...&gt; was triggered by TFoo&lt;T, ...&gt; - but given the work and the compile-time overhead involved, it&#039;s probably not worth the effort.</description>
		<content:encoded><![CDATA[<p>Depends how you recurse. You can easily do that in a loop:</p>
<p>while ((currentType = getSubType(currentType)) != 0)<br />
  allocateSymbolTableEntry (currentType);</p>
<p>As I said, a similar construct compiles fine when using C# or C++. I suspect it works in C# because generics are instantiated at runtime by the CLR, whereas the Delphi compiler has to resolve every instantiation during compile time. In C++ it works because the compiler doesn&#8217;t need more than a forward declaration for a certain type in order to use pointers to that type, so it doesn&#8217;t attempt to actually instantiate the template.</p>
<p>It should be possible to fix without the Halting problem getting in the way &#8211; I guess you would just check whether an instantiation of TFoo&lt;SomethingElse&lt;T, &#8230;&gt;, &#8230;&gt; was triggered by TFoo&lt;T, &#8230;&gt; &#8211; but given the work and the compile-time overhead involved, it&#8217;s probably not worth the effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Mason Wheeler</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-166</link>
		<dc:creator>Mason Wheeler</dc:creator>
		<pubDate>Thu, 11 Mar 2010 14:53:05 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-166</guid>
		<description>Moritz:  Wow, good catch!  I fixed that and now it compiles.  Now I feel a bit embarrassed... :(

Barry:  I see.  Any way to fix this without having to solve the Halting Problem?  Also, I&#039;m a bit surprised that this infinite recursion dies from Out Of Memory (heap exhaustion) and not Stack Overflow.  Isn&#039;t that what usually happens to infinite recursion?</description>
		<content:encoded><![CDATA[<p>Moritz:  Wow, good catch!  I fixed that and now it compiles.  Now I feel a bit embarrassed&#8230; <img src='http://tech.turbu-rpg.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Barry:  I see.  Any way to fix this without having to solve the Halting Problem?  Also, I&#8217;m a bit surprised that this infinite recursion dies from Out Of Memory (heap exhaustion) and not Stack Overflow.  Isn&#8217;t that what usually happens to infinite recursion?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Barry Kelly</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-165</link>
		<dc:creator>Barry Kelly</dc:creator>
		<pubDate>Thu, 11 Mar 2010 10:53:43 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-165</guid>
		<description>As Moritz says, this bug is a failure of the compiler to diagnose infinite recursion in generic type instantiation. The code is invalid, but the compiler tries to instantiate anyway, and gets caught up in the recursion.

The problem type is TNodeList = THierarchyTreeList&lt;THierarchyTreeNode&lt;T&gt;&gt; - it should be TNodeList = THierarchyTreeList&lt;T&gt;.

The ancestor of THierarchyTreeList`1 calls the type constructor of TObjectList`1, but not after first calling the type constructor THierarchyTreeNode`1. But the argument to THierarchyTreeList`1 from TNodeList already included the call to THierarchyTreeNode`1. The instantiation of THierarchyTreeNode`1 will trigger another, different THierarchyTreeList`1, and so on and so forth.</description>
		<content:encoded><![CDATA[<p>As Moritz says, this bug is a failure of the compiler to diagnose infinite recursion in generic type instantiation. The code is invalid, but the compiler tries to instantiate anyway, and gets caught up in the recursion.</p>
<p>The problem type is TNodeList = THierarchyTreeList&lt;THierarchyTreeNode&lt;T&gt;&gt; &#8211; it should be TNodeList = THierarchyTreeList&lt;T&gt;.</p>
<p>The ancestor of THierarchyTreeList`1 calls the type constructor of TObjectList`1, but not after first calling the type constructor THierarchyTreeNode`1. But the argument to THierarchyTreeList`1 from TNodeList already included the call to THierarchyTreeNode`1. The instantiation of THierarchyTreeNode`1 will trigger another, different THierarchyTreeList`1, and so on and so forth.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Warren</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-163</link>
		<dc:creator>Warren</dc:creator>
		<pubDate>Wed, 10 Mar 2010 18:27:34 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-163</guid>
		<description>It is interesting that this code causes the compiler&#039;s VM working size to exceed 1.5 gb on my system, almost immediately.  Imagine how much fun it would be if this bug still existed in a 64-bit compiler that doesn&#039;t have a 32 bit memory cap. :-)

I guess my reluctance to use templated types should be explained the same way that a guy who is scared of arrays would explain himself. It&#039;s not one array that scares me, he would say, it&#039;s an array of array of arrays of arrays.   And so on.  And a list of trees of lists of all templated types.  Well, lots of brackets is one problem there.

I changed the code to make a forward declaration of TEnumerator that is not necessarily a templated type, just so TEnumerator (without ) resolves:

  TEnumerator = class;

  THierarchyTreeNode = class
//  private type
//    TEnumerator = class(TEnumerator)

No more crash.  So that private type appears to be one item on the path of the compiler&#039;s endless recursion  or looping.

W</description>
		<content:encoded><![CDATA[<p>It is interesting that this code causes the compiler&#8217;s VM working size to exceed 1.5 gb on my system, almost immediately.  Imagine how much fun it would be if this bug still existed in a 64-bit compiler that doesn&#8217;t have a 32 bit memory cap. <img src='http://tech.turbu-rpg.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I guess my reluctance to use templated types should be explained the same way that a guy who is scared of arrays would explain himself. It&#8217;s not one array that scares me, he would say, it&#8217;s an array of array of arrays of arrays.   And so on.  And a list of trees of lists of all templated types.  Well, lots of brackets is one problem there.</p>
<p>I changed the code to make a forward declaration of TEnumerator that is not necessarily a templated type, just so TEnumerator (without ) resolves:</p>
<p>  TEnumerator = class;</p>
<p>  THierarchyTreeNode = class<br />
//  private type<br />
//    TEnumerator = class(TEnumerator)</p>
<p>No more crash.  So that private type appears to be one item on the path of the compiler&#8217;s endless recursion  or looping.</p>
<p>W</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Moritz Beutel</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-162</link>
		<dc:creator>Moritz Beutel</dc:creator>
		<pubDate>Wed, 10 Mar 2010 12:28:07 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-162</guid>
		<description>Your comment engine ate my &#039;&lt;&#039; and &#039;&gt;&#039; signs :)
I guess you can figure out what I meant anyway. Just append the missing &lt;T&gt; to THierarchyTreeNode where appropriate.</description>
		<content:encoded><![CDATA[<p>Your comment engine ate my &#8216;&lt;&#8217; and &#8216;&gt;&#8217; signs <img src='http://tech.turbu-rpg.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
I guess you can figure out what I meant anyway. Just append the missing &lt;T&gt; to THierarchyTreeNode where appropriate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Moritz Beutel</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-161</link>
		<dc:creator>Moritz Beutel</dc:creator>
		<pubDate>Wed, 10 Mar 2010 12:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-161</guid>
		<description>Hello Mason,

you say &quot;even though the definition is not infinitely recursive&quot; - I&#039;d give that statement another thought.

THierarchyTreeNode has a list of descendent nodes, FList. This is supposed to be a list of THierarchyTreeNode objects. You declare FList with the type THierarchyTreeList&lt;THierarchyTreeNode&gt;. But THierarchyTreeList inherits from TObjectList&lt;THierarchyTreeNode&gt; - which effectively gives you a list of nodes of type THierarchyTreeNode&lt;THierarchyTreeNode&gt;, which is both recursive and probably not what you&#039;re longing for.

You should be able to get it to work as expected if you define TNodeList = THierarchyTreeList. This will give you a list of descendent nodes of same type, just as you described.</description>
		<content:encoded><![CDATA[<p>Hello Mason,</p>
<p>you say &#8220;even though the definition is not infinitely recursive&#8221; &#8211; I&#8217;d give that statement another thought.</p>
<p>THierarchyTreeNode has a list of descendent nodes, FList. This is supposed to be a list of THierarchyTreeNode objects. You declare FList with the type THierarchyTreeList&lt;THierarchyTreeNode&gt;. But THierarchyTreeList inherits from TObjectList&lt;THierarchyTreeNode&gt; &#8211; which effectively gives you a list of nodes of type THierarchyTreeNode&lt;THierarchyTreeNode&gt;, which is both recursive and probably not what you&#8217;re longing for.</p>
<p>You should be able to get it to work as expected if you define TNodeList = THierarchyTreeList. This will give you a list of descendent nodes of same type, just as you described.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Jolyon Smith</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-160</link>
		<dc:creator>Jolyon Smith</dc:creator>
		<pubDate>Wed, 10 Mar 2010 02:28:38 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-160</guid>
		<description>@Lexi:

&quot;I believe the dev team have such a suite to test out the compiler&quot;

Maybe so, but if they do one of the following MUST pertain:

1) They knew of the bug but chose to release anyway

2) Their test suite doesn&#039;t provide full coverage of all supported syntax - and if it doesn&#039;t cover this case what other cases doesn&#039;t it cover?

3) Their test suite provides 100% coverage but wasn&#039;t part of the QA process subsequent to this syntax change/extension but prior to release</description>
		<content:encoded><![CDATA[<p>@Lexi:</p>
<p>&#8220;I believe the dev team have such a suite to test out the compiler&#8221;</p>
<p>Maybe so, but if they do one of the following MUST pertain:</p>
<p>1) They knew of the bug but chose to release anyway</p>
<p>2) Their test suite doesn&#8217;t provide full coverage of all supported syntax &#8211; and if it doesn&#8217;t cover this case what other cases doesn&#8217;t it cover?</p>
<p>3) Their test suite provides 100% coverage but wasn&#8217;t part of the QA process subsequent to this syntax change/extension but prior to release</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Lex Li</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-159</link>
		<dc:creator>Lex Li</dc:creator>
		<pubDate>Wed, 10 Mar 2010 02:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-159</guid>
		<description>When Embarcadero announced generics support in Delphi, I was surprised that nobody designs a test suite for that to check whether at that moment Delphi supports all or most features available in C++/Java/C#. I believe the dev team have such a suite to test out the compiler and hope some day they can show that publicly. It is not a shame that some test cases fail, but it can be improved in future versions.

Like Nick Hodges once reported, the compiler is under heavy redesign and reimplementation to achieve C++Builder/Delphi parity and multi-platform support. The opportunity is that such a new compiler architecture should make C++ 0x and Delphi generics support complete.</description>
		<content:encoded><![CDATA[<p>When Embarcadero announced generics support in Delphi, I was surprised that nobody designs a test suite for that to check whether at that moment Delphi supports all or most features available in C++/Java/C#. I believe the dev team have such a suite to test out the compiler and hope some day they can show that publicly. It is not a shame that some test cases fail, but it can be improved in future versions.</p>
<p>Like Nick Hodges once reported, the compiler is under heavy redesign and reimplementation to achieve C++Builder/Delphi parity and multi-platform support. The opportunity is that such a new compiler architecture should make C++ 0x and Delphi generics support complete.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Mason Wheeler</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-158</link>
		<dc:creator>Mason Wheeler</dc:creator>
		<pubDate>Tue, 09 Mar 2010 21:38:21 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-158</guid>
		<description>Jim:  I should have phrased that more clearly.  The Generics issues have made the more recent compilers less stable than D2007&#039;s.  2010 is definitely an improvement over 2009, though!

Bryden: Yeah, that&#039;s about how I had it figured too.  The question is, why?  According to Moritz Beutel, this concept works just fine with C++ templates and C# generics, and the concept itself isn&#039;t inherently recursive, so it shouldn&#039;t throw the compiler into an infinite loop.  I think it just doesn&#039;t quite realize that it doesn&#039;t have a type for T yet, so it keeps going around in circles looking for it.</description>
		<content:encoded><![CDATA[<p>Jim:  I should have phrased that more clearly.  The Generics issues have made the more recent compilers less stable than D2007&#8217;s.  2010 is definitely an improvement over 2009, though!</p>
<p>Bryden: Yeah, that&#8217;s about how I had it figured too.  The question is, why?  According to Moritz Beutel, this concept works just fine with C++ templates and C# generics, and the concept itself isn&#8217;t inherently recursive, so it shouldn&#8217;t throw the compiler into an infinite loop.  I think it just doesn&#8217;t quite realize that it doesn&#8217;t have a type for T yet, so it keeps going around in circles looking for it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on How to break the D2010 compiler by Bryden</title>
		<link>http://tech.turbu-rpg.com/90/how-to-break-the-d2010-compiler/comment-page-1#comment-157</link>
		<dc:creator>Bryden</dc:creator>
		<pubDate>Tue, 09 Mar 2010 20:42:23 +0000</pubDate>
		<guid isPermaLink="false">http://tech.turbu-rpg.com/?p=90#comment-157</guid>
		<description>I&#039;ve got a sneaking suspicion that defining the TNodeList type may in fact be allowing the infinite recursion. I can&#039;t quite put my finger on why I suspect that, although that may force a resolve of the generics immediately.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve got a sneaking suspicion that defining the TNodeList type may in fact be allowing the infinite recursion. I can&#8217;t quite put my finger on why I suspect that, although that may force a resolve of the generics immediately.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
