> -----Original Message----- > From: Jacob Oettinger [mailto:ja...@oettinger.dk] > Sent: 08 June 2010 14:09 > > On 08/06/2010, at 12.41, Johannes Schlüter wrote: > > > On Tue, 2010-06-08 at 12:23 +0200, Jacob Oettinger wrote: > >> Would it be equally simple to allow the syntax below? > >> > >> $result = new ResultMaker()->getIt(); > > > > does this mean > > > > $result = new (ResultMaker()->getIt()); > > > > or > > > > $result = (new ResultMaker())->getIt(); > > > > I assume the later, but that is non-obvious as we allow > > > > $result = new $class(); > > Yes the later. I do not see how the above makes it non-obvious.
I think the only problem with deciding which it means is that -> and () are not defined as operators in the PHP documentation, and as such do not have a clearly-defined precedence and associativity. In Javascript, "." (property access) and "()" (function call) both appear in the operator precedence table, so there are definite rules for ascertaining the meaning of such a construct. Up until recently this probably hasn't really been a problem, as it's not been possible to write constructs that needed these rules to decipher them. However, with the previous addition of object access chaining, and now array dereferencing, the time has almost certainly come to add -> and () to the operator documentation, with appropriate precedence and associativity. (Incidentally, other operators which are not documented in the "Operators" section, and probably should be, include :: (which *is* described in the "Classes and Objects" section as the "Scope Resolution Operator", and \ (namespace separator).) Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: m.f...@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php