Re: Feature request

From: Date: Tue, 21 Nov 2006 03:44:53 +0000
Subject: Re: Feature request
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-26693@lists.php.net to get a copy of this message
Rick Widmer wrote: > I like the idea of f()[1] meaning return the [1] element of an array or > character returned by f(). f(){1} should also return a character from a > string. On the other hand, foo()[1] = 4; is a syntax error, plain and > simple. The way I see it functions RETURN values. You can't assign to > a function, so why should you be able to assign to an element of it? > > What am I missing? You're missing the fact that f()[1] means the second element of the array RETURNED by f(), not the second element of f(). Therefore f()[1] = 'a'; is perfectly valid. It assigns the value 'a' to the second element of the array returned by f() -- which, by the way, might be returned by reference or might actually be an object with array-access syntax. If it's neither of these then the assignment does nothing, but so what? -- Jasper Bryant-Greene Director Album Limited jasper@albumltd.co.nz +64 21 708 334 / 0800 425 286 http://www.albumltd.co.nz/

« previous php.internals (#26693) next »