Re: Return type hinting patch

From: Date: Sun, 27 Apr 2008 20:23:02 +0000
Subject: Re: Return type hinting patch
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-37263@lists.php.net to get a copy of this message
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 larry@garfieldtech.com 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

« previous php.internals (#37263) next »