Re: Feature request

From: Date: Mon, 20 Nov 2006 21:09:54 +0000
Subject: Re: Feature request
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-26683@lists.php.net to get a copy of this message
On Thu, November 9, 2006 11:48 pm, Stanislav Malyshev wrote: >> There are some cases where this could start becoming quite >> challenging and >> we might get into reference counting/separation problems, i.e.: >> >> function foo() >> { >> return array(1,2,3); >> >> } >> foo()[1] = 4; > > I'd say expression(f()[1]) means $tmp = f(); expression($tmp); > unset($tmp); which here means: > $tmp = foo(); > $tmp[1] = 4; > unset($tmp); > > which is meaningless but should work. IIRC the engine can make free's > at > the end of expression, so it shouldn't be big problem. Actually, any > assignment to it if it's not returned by-ref is meaningless, but > syntactically ok. Last I checked, if foo() returned a string, the $tmp code above would alter the string contents... I rarely do this, but that's what I would expect it to do... But is it altering the original string, or a copy of the string or ??? You could make a ruling that this nifty new syntax is "read only" on the data, and you can't assign to it, but that's not what this naive reader would expect if this ()[] syntax is going to be supported. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

« previous php.internals (#26683) next »