Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42460 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94260 invoked from network); 3 Jan 2009 13:13:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2009 13:13:12 -0000 X-Host-Fingerprint: 83.6.244.56 abdc56.neoplus.adsl.tpnet.pl Received: from [83.6.244.56] ([83.6.244.56:13795] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/22-12810-4646F594 for ; Sat, 03 Jan 2009 08:13:11 -0500 To: internals@lists.php.net,Marcus Boerger Message-ID: <495F6457.6060201@crystalpoint.pl> Date: Sat, 03 Jan 2009 14:12:55 +0100 User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 CC: internals@lists.php.net References: <87.E1.28540.1817E594@pb1.pair.com> <1811359335.20090102211222@marcus-boerger.de> In-Reply-To: <1811359335.20090102211222@marcus-boerger.de> Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 83.6.244.56 Subject: Re: [PHP-DEV] Closures serialization From: m.kurzyna@crystalpoint.pl (Marcin Kurzyna) Hi Marcus, > You would need to provide a c level serialization that stores the $this > pointer (the easy part) and the zend_function member (not easy). The > second part requires storing of all static variables, which again is > pretty easy but it also requires to store the function itself, which in > case of a user function probably only means the string but then at the > time of serialization you only have the compiled opcodes. So you would > need APC to serialize the opcodes, which is not yet implemented. > Alternatively you could save the implementation string somewhere. And > serialize that and compiling it upon unserialization. If you're more > interested, c level serialization with multiple serialization inputs is > used for: SplObjectStorage::serialize() / unserialize(). thnx for your insight. i've looked at SplObjectStorage::serialize and it seems pretty straight forward - this shouldn't be a problem. as you said it's saving the zend_function member that is tricky. i thought i'd go with saving function string and recompiling it as you suggested (i don't want to mess with APC although i find the idea of opcode serialization much more appealing). anyway it's proving itself, well... tricky ;-) i'm thinking about hooking into zend_do_beging_lambda_function_declaration and saving all until zend_do_end_function_declaration, but i haven't tried that in practice yet (not even sure how to do this at the moment - i'll get to it tonight). thnx marcin