On 07/11/2016 11:30 AM, Rasmus Schultz wrote:
what's the actual added value of this sort of operator?
The only direct value to the language is brevity - mere convenience.

But I think the biggest indirectly added value, is that this will
discourage people from the chainable methods anti-pattern - so this
has value to the community; those who write chainable methods can
stop, and those who want chainable methods can get a wider choice of
libraries that were previously too verbose in use for their taste.

As one of those proponents of chained methods / returning $this, I quite like this proposal. It neatly handles many (although not all) of the use cases for method chaining, specifically the most controversial ones, while not having any of the same potential issues. (Eg, when composing and delegating the method call to another object, you have to do some $this juggling.) It would not remove the need for all method chaining, but it would remove the need for the controversial ones that Rasmus is complaining about while letting people like me still write nicely compact and readable code. :-)

(Modulo implementation details and debating the operator symbol for a few weeks, as per usual.)

--Larry Garfield

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to