<?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: Extending PHP 5.3 Closures with Serialization and Reflection</title>
	<atom:link href="http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/</link>
	<description>A Web Development Blog by Synapse Studios</description>
	<lastBuildDate>Sun, 05 Feb 2012 02:47:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Jeremy Lindblom</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-1090</link>
		<dc:creator>Jeremy Lindblom</dc:creator>
		<pubDate>Wed, 18 Jan 2012 19:42:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-1090</guid>
		<description>Eric,

Thanks for the feedback. You raise some good points about caching that I would like to look into. I realize that there are limitations to my approach, which is why I have never recommended using my class (or even the concept) in a production environment. It is not exactly a practical piece of code, it&#039;s more exploratory. 

You should check out my newer version in a github branch: https://github.com/jeremeamia/super_closure/tree/develop. This one does a better job at parsing the code (using php lexical tokenizer) such that the &quot;source file formatting&quot; problems you mentioned are not an issue. Not exactly a performance increase, but definitely more stable.</description>
		<content:encoded><![CDATA[<p>Eric,</p>
<p>Thanks for the feedback. You raise some good points about caching that I would like to look into. I realize that there are limitations to my approach, which is why I have never recommended using my class (or even the concept) in a production environment. It is not exactly a practical piece of code, it&#8217;s more exploratory. </p>
<p>You should check out my newer version in a github branch: <a href="https://github.com/jeremeamia/super_closure/tree/develop" rel="nofollow">https://github.com/jeremeamia/super_closure/tree/develop</a>. This one does a better job at parsing the code (using php lexical tokenizer) such that the &#8220;source file formatting&#8221; problems you mentioned are not an issue. Not exactly a performance increase, but definitely more stable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Stevens</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-1088</link>
		<dc:creator>Eric Stevens</dc:creator>
		<pubDate>Wed, 11 Jan 2012 16:40:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-1088</guid>
		<description>Sorry to double-post, but it occurs to me that you could use a combination of private static properties on the object, and and spl_object_hash() to determine whether two Closures being serialized are instances of the same original Closure or not, and reuse the previously deserialized method if so.  You&#039;ll have a hard time restoring correct scopes for the use() variables, but at least you can save yourself the overhead of repeated interpreter spinups, as well as reduce the memory footprint in the process.</description>
		<content:encoded><![CDATA[<p>Sorry to double-post, but it occurs to me that you could use a combination of private static properties on the object, and and spl_object_hash() to determine whether two Closures being serialized are instances of the same original Closure or not, and reuse the previously deserialized method if so.  You&#8217;ll have a hard time restoring correct scopes for the use() variables, but at least you can save yourself the overhead of repeated interpreter spinups, as well as reduce the memory footprint in the process.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Stevens</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-1087</link>
		<dc:creator>Eric Stevens</dc:creator>
		<pubDate>Wed, 11 Jan 2012 16:36:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-1087</guid>
		<description>Too bad this has to rely on eval() to work correctly.  But I&#039;m not sure there&#039;s an alternative, really.  In an environment which takes advantage of PHP Opcode Cache (such as relying on extensions like APC) - which any production environment should be - this will come with a substantial performance penalty.  eval() spins up the PHP interpreter, and it will have to be spun up for every deserialized function.  

It also means multiple instances of the same closure will each use their own memory (rather than sharing memory as they would in their original instantiation), both in terms of their use() parameters and their actual executable opcode.

It&#039;s also a little fragile with respect to source file formatting, the original Closure function needs to be on lines of its own, with no surrounding markup bleeding over.

Still, it&#039;s clever, and to the best of my knowledge there is not a better way to accomplish serializing a Closure.  Even opcode caching doesn&#039;t provide a path to this end without using a separate intermediary file (defeating the point of serialization).</description>
		<content:encoded><![CDATA[<p>Too bad this has to rely on eval() to work correctly.  But I&#8217;m not sure there&#8217;s an alternative, really.  In an environment which takes advantage of PHP Opcode Cache (such as relying on extensions like APC) &#8211; which any production environment should be &#8211; this will come with a substantial performance penalty.  eval() spins up the PHP interpreter, and it will have to be spun up for every deserialized function.  </p>
<p>It also means multiple instances of the same closure will each use their own memory (rather than sharing memory as they would in their original instantiation), both in terms of their use() parameters and their actual executable opcode.</p>
<p>It&#8217;s also a little fragile with respect to source file formatting, the original Closure function needs to be on lines of its own, with no surrounding markup bleeding over.</p>
<p>Still, it&#8217;s clever, and to the best of my knowledge there is not a better way to accomplish serializing a Closure.  Even opcode caching doesn&#8217;t provide a path to this end without using a separate intermediary file (defeating the point of serialization).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: PHP APC Tutorial – cz.3: User Variable Cache – Czyli optymalizacja skryptów PHP &#124; Opolski Portal Programistyczny</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-1009</link>
		<dc:creator>PHP APC Tutorial – cz.3: User Variable Cache – Czyli optymalizacja skryptów PHP &#124; Opolski Portal Programistyczny</dc:creator>
		<pubDate>Sat, 26 Nov 2011 12:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-1009</guid>
		<description>[...] należy zastosować specjalną klasę opisaną przez Pana co się zowie Jeremy Lindblom opisaną tutaj, a dostępną do ściągnięcia tutaj. Wtedy można tego dokonać w następujący [...]</description>
		<content:encoded><![CDATA[<p>[...] należy zastosować specjalną klasę opisaną przez Pana co się zowie Jeremy Lindblom opisaną tutaj, a dostępną do ściągnięcia tutaj. Wtedy można tego dokonać w następujący [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erin</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-968</link>
		<dc:creator>Erin</dc:creator>
		<pubDate>Thu, 27 Oct 2011 03:27:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-968</guid>
		<description>Awesome piece of code, even if it is a little sad that closures can&#039;t be natively serialized. It does make some sense I suppose given that pass-by-reference would be impossible.

It would be really cool if you could throw an exception when attempting to serialize a closure that *does* have pass-by-reference parameters.

I have an idea for something really cool that can be achieved using this. I&#039;ll keep you posted if I can pull it off ;)</description>
		<content:encoded><![CDATA[<p>Awesome piece of code, even if it is a little sad that closures can&#8217;t be natively serialized. It does make some sense I suppose given that pass-by-reference would be impossible.</p>
<p>It would be really cool if you could throw an exception when attempting to serialize a closure that *does* have pass-by-reference parameters.</p>
<p>I have an idea for something really cool that can be achieved using this. I&#8217;ll keep you posted if I can pull it off ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tyron</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-897</link>
		<dc:creator>Tyron</dc:creator>
		<pubDate>Thu, 12 May 2011 20:37:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-897</guid>
		<description>Sweet, thanks for this piece of code!</description>
		<content:encoded><![CDATA[<p>Sweet, thanks for this piece of code!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AzPHP User&#039;s Group &#187; Blog Archive &#187; PHP Object Oriented Programming Reinvented and Serializing Closures</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-693</link>
		<dc:creator>AzPHP User&#039;s Group &#187; Blog Archive &#187; PHP Object Oriented Programming Reinvented and Serializing Closures</dc:creator>
		<pubDate>Wed, 29 Sep 2010 18:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-693</guid>
		<description>[...] http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/ [...]</description>
		<content:encoded><![CDATA[<p>[...] <a href="http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/" rel="nofollow">http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Muyser</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-575</link>
		<dc:creator>Eric Muyser</dc:creator>
		<pubDate>Tue, 25 May 2010 03:32:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-575</guid>
		<description>Ah right right right. &quot;same request&quot; is the difference. I&#039;m using this in context of a cron trying to IPC with an FFMPEG service. Lambdas are the key, otherwise it&#039;s simply too messy imo. It&#039;s easy to just store an ID somewhere for later, like it does now, but your article was a good direction towards abstracting it. So you&#039;re serializing it in an HTTP request for a different request. Very cool :] I&#039;m going to keep an eye out for when I might need such functionality.</description>
		<content:encoded><![CDATA[<p>Ah right right right. &#8220;same request&#8221; is the difference. I&#8217;m using this in context of a cron trying to IPC with an FFMPEG service. Lambdas are the key, otherwise it&#8217;s simply too messy imo. It&#8217;s easy to just store an ID somewhere for later, like it does now, but your article was a good direction towards abstracting it. So you&#8217;re serializing it in an HTTP request for a different request. Very cool :] I&#8217;m going to keep an eye out for when I might need such functionality.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeremy Lindblom</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-574</link>
		<dc:creator>Jeremy Lindblom</dc:creator>
		<pubDate>Mon, 24 May 2010 18:19:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-574</guid>
		<description>Thanks Eric. My script is geared towards serializing the Closure across multiple requests, so preserving the variables passed-by-reference is not really a concern, because the references are lost once the request ends. I&#039;m pretty sure there&#039;s nothing that can be done about that. I&#039;m not entirely sure why I would want to serialize and unserialize the closure in the same request anyway. (And yes, I&#039;m aware of code hinting, I just opted for the Exception in this example.)</description>
		<content:encoded><![CDATA[<p>Thanks Eric. My script is geared towards serializing the Closure across multiple requests, so preserving the variables passed-by-reference is not really a concern, because the references are lost once the request ends. I&#8217;m pretty sure there&#8217;s nothing that can be done about that. I&#8217;m not entirely sure why I would want to serialize and unserialize the closure in the same request anyway. (And yes, I&#8217;m aware of code hinting, I just opted for the Exception in this example.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Muyser</title>
		<link>http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/comment-page-1/#comment-573</link>
		<dc:creator>Eric Muyser</dc:creator>
		<pubDate>Sun, 23 May 2010 16:18:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.htmlist.com/?p=551#comment-573</guid>
		<description>I actually went a different way with yours as inspiration. Not sure though (haven&#039;t tested much).

http://eric.muyser.com/php-class-lambda/

Thoughts? BTW PHP has code hinting (your line #10)</description>
		<content:encoded><![CDATA[<p>I actually went a different way with yours as inspiration. Not sure though (haven&#8217;t tested much).</p>
<p><a href="http://eric.muyser.com/php-class-lambda/" rel="nofollow">http://eric.muyser.com/php-class-lambda/</a></p>
<p>Thoughts? BTW PHP has code hinting (your line #10)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

