Re: Code References
| From: | George Schlossnagle | Date: | Mon, 19 May 2003 15:28:40 +0000 |
| Subject: | Re: Code References | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-1718@lists.php.net to get a copy of this message | ||
On Monday, May 19, 2003, at 09:56 AM, Sterling Hughes wrote:
On Mon, 2003-05-19 at 11:09, Zeev Suraski wrote:I agree with you completely on the aesthetics. The quoting makes it as hard to read as a double-quoted perl eval. Zeev is right re: the performance though. The eval is only performed once (though it is of course an eval), which is only marginally more expensive than compiling it completely at script compile time, and that assumes that you always end up compiling it.At 16:34 19/05/2003, Sterling Hughes wrote:That's why one has eval. Create_function() is a really hacky way of having closures/callbacks. Its not only inefficient, its ugly. create_function() is hardly ever used because its such an inelegant (and inefficient) way of doing things. From a syntax perspective anonymous functions are much clearer (the problem with single quotes is you need to then escape all single quotes).On Mon, 2003-05-19 at 10:55, Wez Furlong wrote:And so does PHP, through create_function, using PHPish syntax. create_function is not related in any way to call_user_func(), it's fairly fast, and will be faster. I don't see any additional things that are supported by this syntax, other than a tiny performance gain, that comes at the price of significantly reduced functionality (the code cannot contain anything dynamic, whereas with create_function, it can).use perl;Python, Ruby, LISP, Java, C, whatever, all support this in some form or another (whether it be function pointers or code references.)