Re: Re: PATCH: anonymous functions in PHP
| From: | Wez Furlong | Date: | Mon, 19 Mar 2007 01:30:37 +0000 |
| Subject: | Re: Re: PATCH: anonymous functions in PHP | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28405@lists.php.net to get a copy of this message | ||
Your nitpicking happens to be wrong ;-)
sizeof("string constant") is the "same" as strlen("string constant")+1, but is resolved at compile time, so we use sizeof("string constant")-1 to get a compile time evaluated strlen(). This trick is used throughout the PHP internals.
--Wez.
On Mar 18, 2007, at 9:27 PM, Gwynne wrote:
On Mar 18, 2007, at 8:48 PM, Wez Furlong wrote:Updated patch at http://pastebin.ca/400952 Not 100% sure if my hack in zend_compile.c is righteous, but it doesn't seem too far wrong.74. + if (!memcmp(opline-op2.u.constant.value.str.val, "__zend_anon_", sizeof("__zend_anon_")-1)) {Pardon my nitpicking, but shouldn't this be:74. + if (!memcmp(opline-op2.u.constant.value.str.val, "__zend_anon_", strlen("__zend_anon_")-1)) {Also, a strong +1 for this patch, I'd love to see this support in PHP. -- Gwynne, Daughter of the Code "This whole world is an asylum for the incurable."