<?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: Closures In Straight C</title>
	<atom:link href="http://porkrind.org/missives/closures-in-straight-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://porkrind.org/missives/closures-in-straight-c/</link>
	<description>Portal For The Masses</description>
	<lastBuildDate>Thu, 26 Jan 2012 00:00:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: hopia</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-485</link>
		<dc:creator>hopia</dc:creator>
		<pubDate>Wed, 14 Dec 2011 17:25:33 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-485</guid>
		<description>As a long time C developer, I totally agree that callbacks and cookies are the closest thing to closures in the C world.  Of course, we all know it&#039;s not part of the language, so it&#039;s not as intuitive and natural to use.  However, I think the point of the article is that C developers can and have been able to &quot;simulate&quot; the behavior.</description>
		<content:encoded><![CDATA[<p>As a long time C developer, I totally agree that callbacks and cookies are the closest thing to closures in the C world.  Of course, we all know it&#8217;s not part of the language, so it&#8217;s not as intuitive and natural to use.  However, I think the point of the article is that C developers can and have been able to &#8220;simulate&#8221; the behavior.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-18</link>
		<dc:creator>David</dc:creator>
		<pubDate>Sun, 11 Jun 2006 20:39:35 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-18</guid>
		<description>&lt;p&gt;Douglas, I&#8217;m not sure what you mean by &#8220;everything&#8221;. Please explain.&lt;/p&gt;
&lt;p&gt;You could keep a pointer to you local variables (if you were sure the callback were going to happen before they go away) or you could use the variables in the created structure instead of locals (this is what C folk tend to do in these cases).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Douglas, I&#8217;m not sure what you mean by &#8220;everything&#8221;. Please explain.</p>
<p>You could keep a pointer to you local variables (if you were sure the callback were going to happen before they go away) or you could use the variables in the created structure instead of locals (this is what C folk tend to do in these cases).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Douglas</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-17</link>
		<dc:creator>Douglas</dc:creator>
		<pubDate>Sat, 10 Jun 2006 12:13:16 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-17</guid>
		<description>&lt;p&gt;The difference is the same as between &#8220;I want X, Y and Z&#8221; and &#8220;I want everything&#8221;. &lt;/p&gt;
&lt;p&gt;If you only want X, Y and Z in the first place, that&#8217;s going to be fine, it will work in that limited case. But I don&#8217;t know how you&#8217;d express &#8220;everything&#8221; in C.&lt;/p&gt;
&lt;p&gt;What you want is a pointer to the current scope, not a pointer to a copy of some of the variables from the current scope.&lt;/p&gt;
&lt;p&gt;Douglas&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The difference is the same as between &#8220;I want X, Y and Z&#8221; and &#8220;I want everything&#8221;. </p>
<p>If you only want X, Y and Z in the first place, that&#8217;s going to be fine, it will work in that limited case. But I don&#8217;t know how you&#8217;d express &#8220;everything&#8221; in C.</p>
<p>What you want is a pointer to the current scope, not a pointer to a copy of some of the variables from the current scope.</p>
<p>Douglas</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-16</link>
		<dc:creator>David</dc:creator>
		<pubDate>Sat, 10 Jun 2006 10:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-16</guid>
		<description>&lt;p&gt;But you see, that is my point. The &#8220;closing over itself&#8221; is just syntactic sugar.&lt;/p&gt;
&lt;p&gt;C only supports 2 types of variables. Global variables and stack based local variables. Anything  more than that is supported by the standard library&#8212;malloc, to be specific.&lt;/p&gt;
&lt;p&gt;The point is that you have to hand hold C to get anything that lasts longer than a local stack variable but shorter than a global variable (which lasts forever).&lt;/p&gt;
&lt;p&gt;By passing these user data pointers around with the function pointer itself, you are effectively passing around your local lexical environment&#8212;just the parts you care about.&lt;/p&gt;
&lt;p&gt;Like you guys pointed out (and as I said in the article), it&#8217;s painful to  do compared to a language with language level closures.&lt;/p&gt;
&lt;p&gt;But that&#8217;s the way it is with C for practically everything! It&#8217;s the exact same concept as a closure, regardless of how much extra you have to do to implement it&#8230;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>But you see, that is my point. The &#8220;closing over itself&#8221; is just syntactic sugar.</p>
<p>C only supports 2 types of variables. Global variables and stack based local variables. Anything  more than that is supported by the standard library&#8212;malloc, to be specific.</p>
<p>The point is that you have to hand hold C to get anything that lasts longer than a local stack variable but shorter than a global variable (which lasts forever).</p>
<p>By passing these user data pointers around with the function pointer itself, you are effectively passing around your local lexical environment&#8212;just the parts you care about.</p>
<p>Like you guys pointed out (and as I said in the article), it&#8217;s painful to  do compared to a language with language level closures.</p>
<p>But that&#8217;s the way it is with C for practically everything! It&#8217;s the exact same concept as a closure, regardless of how much extra you have to do to implement it&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Davis</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-15</link>
		<dc:creator>Ryan Davis</dc:creator>
		<pubDate>Sat, 10 Jun 2006 08:37:34 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-15</guid>
		<description>&lt;p&gt;Thirded. Not even close to closures.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thirded. Not even close to closures.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blake Watters</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-14</link>
		<dc:creator>Blake Watters</dc:creator>
		<pubDate>Sat, 10 Jun 2006 08:33:19 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-14</guid>
		<description>&lt;p&gt;Those are just pointers to data. A closure has to &#8216;close over&#8217; its lexical scope, restoring its state and scope at run time.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Those are just pointers to data. A closure has to &#8216;close over&#8217; its lexical scope, restoring its state and scope at run time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ratatask</title>
		<link>http://porkrind.org/missives/closures-in-straight-c/comment-page-1/#comment-13</link>
		<dc:creator>ratatask</dc:creator>
		<pubDate>Sat, 10 Jun 2006 07:41:14 +0000</pubDate>
		<guid isPermaLink="false">http://porkrind.org/missives2/?p=13#comment-13</guid>
		<description>&lt;p&gt;This isn&#8217;t really closure &#8211; you have to manually create the environment you want to capture (your struct) and make it have dynamic extent(stuff it at file scope or malloc it).&lt;/p&gt;
&lt;p&gt;Extremly painful compared to languages with real closures.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>This isn&#8217;t really closure &#8211; you have to manually create the environment you want to capture (your struct) and make it have dynamic extent(stuff it at file scope or malloc it).</p>
<p>Extremly painful compared to languages with real closures.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- This Quick Cache file was built for (  porkrind.org/missives/closures-in-straight-c/feed/ ) in 0.15608 seconds, on Feb 9th, 2012 at 10:44 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 11:44 am UTC -->
