Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP is awesome

Name: Anonymous 2007-08-28 17:56 ID:xY3vpdBA

This is how you create a anonymous function in PHP:

$newfunc = create_function('$a,$b', 'return "ln($a) + ln($b) = " . log($a * $b);');


Name: Anonymous 2007-08-30 15:15 ID:DLtHHP7w

Of course, you can't expect for ($i = 100000; --$i; lambda(...)); to work decently.
why not? stuff like that works just fine in javascript...
var a=new Array();
for( i = 100000; --i ; (function(){ a[i] = i })() );
alert(a.length)

Name: Anonymous 2007-08-30 15:35 ID:Heaven

>>39
No shit it was the same person. Fourchon is so slow I didn't think it took my first post. Perhaps it needs an EXPERT PROGRAMMER to rewrite it.

>It's not noticeably slow if you don't abuse it. Of course, you can't expect for ($i = 100000; --$i; lambda(...)); to work decently.

Why would you not expect a loop creating lambdas to work decently? I've done that in plenty of other languages. What's the excuse there?

>It's not noticeably slow if you don't abuse it. Of course, you can't expect for ($i = 100000; --$i; lambda(...)); to work decently.

create_function() just blindly calls eval on code passed into it. Oops!

Also, let's not forget the fact that Zend ignores optimizations on eval()ed code.

All of this adds up to one thing -- PHP's create_function and eval are horribly fucked... much like the language itself.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List