On Sunday 27 April 2008, Alain Williams wrote: > On Sat, Apr 26, 2008 at 05:11:29PM -0700, Chris Stockton wrote: > > *cough* lambda *cough* > > That would be nice, but the scoping of variables in PHP doesn't seem to > make that nice, the code below results in '' Undefined variable: aa '' > if I take the 'global' statement out, if I leave it in the echo in b() > shows it as the empty string. > > Getting this right would be nice as it would allow (what has been explained > to me at any rate) functional programming if a() returns an anonymous b(). > The stuff below works in perl and python. > > > function a($aa) { > echo "a called aa=$aa\n"; > function b() { > global $aa; > echo "in b aa=$aa\n"; > } > > b(); > } > > a('this is aa');
The suggestion when last this was discussed was to introduce a keyword "lexical" that would mean "pull this variable in from the lexical parent of this function, with the same semantics as pulling in a global variable". Aside from the introduction of another reserved word, it seemed like a well-received idea and a good solution. -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php