Re: Re: PATCH: anonymous functions in PHP

From: Date: Mon, 17 Dec 2007 19:46:42 +0000
Subject: Re: Re: PATCH: anonymous functions in PHP
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-34072@lists.php.net to get a copy of this message
Functionally, create_function() is a variation of eval, which allows you to create new code at runtime. Static lambda is syntactic sugar for creating a function in the global scope, without knowing its name at compile time. Static lambda is more restrictive than
While we are at it, what's wrong with knowing the name? I can see why closure can be fun when you can dynamically use outer-scope variables. But when you can't, what exactly prevents one from just doing the function?
two considerations to take here; First, how probable is it, that users will make this assumption? And second, how much confusion will it cause to those, which it affects?
First, about 100% on the first encounter for any user ever seeing closures in any other language. Second, all the confusion possible, like "oh, closures! cool! let me do this and that! what, I can't use variables?! Are you kidding me?! WTF is it useful for?!"
place. The simple rule, that PHP has dynamic scope, should be simple to understand for anyone who actually knows the difference.
I'm not sure I understand what you mean by "static scope" and "dynamic scope", but anyway thing that looks like closure but works like regular function definition that isn't - is not a very good idea, IMO. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#34072) next »