Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34631 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34276 invoked by uid 1010); 10 Jan 2008 10:09:32 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34261 invoked from network); 10 Jan 2008 10:09:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2008 10:09:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=rsky0711@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rsky0711@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.166.180 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rsky0711@gmail.com X-Host-Fingerprint: 64.233.166.180 py-out-1112.google.com Received: from [64.233.166.180] ([64.233.166.180:32577] helo=py-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6E/C3-03358-ADEE5874 for ; Thu, 10 Jan 2008 05:09:32 -0500 Received: by py-out-1112.google.com with SMTP id u77so688536pyb.16 for ; Thu, 10 Jan 2008 02:09:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:mime-version:content-type:content-transfer-encoding:content-disposition; bh=6IsTtvPgxUDsm+oMz1n7x3+6gyMZMR27Tv/YobCO9qA=; b=ZwvJdwejM2JEdxM1gj4H6JgUuey0t3fu1Jn/7uge5li/VHbCHfioTSQQxYLtqGW2OcVa+BoABC+Auix0aEBwMWdAfYCbOTOD27XGqC/JlYnHmabekNoc36Jhax6dnzPHgfAf+bWWzwqQudfRgAsbSHmfLGA7hlx4VEzZOf8B2Gc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:mime-version:content-type:content-transfer-encoding:content-disposition; b=e+Rf9g3Yz9HbqvTatHppbY4uVbiuAmFzTIQlOO1CE7WzAdQewLLZQWzxWVFH4TP8XjxmoV+Y963cm7ruBPiRfNhU18bFZXQP36YaYlge0k1i0nm0ifkqJi3M042CYOSQTnd4GjBbWZcXIY6B7VqUimwJVVz+oMAkIn6EeapDcNI= Received: by 10.142.73.8 with SMTP id v8mr775342wfa.68.1199959766884; Thu, 10 Jan 2008 02:09:26 -0800 (PST) Received: by 10.70.15.16 with HTTP; Thu, 10 Jan 2008 02:09:26 -0800 (PST) Message-ID: Date: Thu, 10 Jan 2008 19:09:26 +0900 To: internals@lists.php.net Cc: "Marcus Boerger" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: [RFC] Anonymous functions From: rsky0711@gmail.com ("Ryusuke SEKIYAMA") Hello, lists, We have discussed about implementing anonymous functions and closures in PHP. However, I consider that implementing anonymous functions and implementing lexical scopes should be discussed separately. # Even though I like closure. ;-) So I wrote anonymous function patch for PHP 5.3 and 6.0. Patches (inlcude tests): for PHP 5.3: http://www.opendogs.org/pub/php-5.3dev-080109-anon.patch for PHP 6.0: http://www.opendogs.org/pub/php-6.0dev-080109-anon.patch Featues: - Unlike create_function(), there is no need to take care of quotes, backslashes and dollars . - Can be used in loop, but be compiled only once. - Supports recursive call using __FUNCTION__. - Supports inline execution. It works like a block scope. - Works with opcode caches. Since I couldn't build APC against PHP 5.3, I have tested PHP 5.2.5 + anonymous function patch and APC 3.0.16. Example: The anonymous function name is composed of '\0', "ZEND_ANON<#serial>", filename and character position. - Leading '\0' blocks to be displayed by get_defined_functions(). - "ZEND_ANON<" helps determine wheter the function is anonymous or not because '<' cannot be used for user-defined function name. - Serial number and file informations make the name unique. - char anon_key_buf[32] is long enough because `snprintf(anon_key_buf, 32, "ZEND_ANON<%llu>", (unsigned long long)UINT64_MAX)' returns 31. Regards, 2008/1/6, Marcus Boerger : > Hello Stanislav, > > tha makesw three then already, how about we ask around again? > Ryusuke, can you please start a new '[RFC] Square brackets shortcut' thread > to collect opinions and pass along the patch for that? > > I like the anonymous function patch too. It is clean and simple. Maybe you > want to start a second '[RFC] Anonymous functions' thread with that patch. > > Can you also please add tests for both? > > marcus > > Wednesday, January 2, 2008, 7:51:06 PM, you wrote: > > >> the square bracket array syntax patch for PHP 5.3, > >> http://www.opendogs.org/pub/php-5.3dev-080101-sbar.patch > > > I remember we discussed that already and it was rejected then (even > > though myself and Andi liked it) - did the people that objected then > > change their minds? > > > > Best regards, > Marcus > > -- /** * Ryusuke SEKIYAMA * rsky0711@gmail.com */