Hi!

> Hilarious to hear you cite that as the already existing inconsistency
> between += and ++ with non-numeric strings came up only last week.
> 
> $x = 'foo';
> $x++; // $x === 'fop'
> $x += 1; // $x === 1

Exactly, because on strings ++ and += 1 are not the same operator. And,
as you noted, it requires a pause to figure it out. But now imagine
somebody overrides + and ++ to work on files, doing whatever sounded
clever at the moment - how easy would it be to read that code? To
maintain it? That's my concern.
I do agree that is a question of judgement if we want this kind of
magic. Right now I am leaning to the "no" side, especially given the RFC
lacks the description of the actual use cases. I mean, the coolness
factor is there, all the cool boys - C++, Python, Swift, Scala - do
that, but I'd like to see what are the use cases specifically for PHP.

> That's a significant difference in terms of semantics if there are
> other references to $x lying around.  Nevermind the cost of
> newing/cloning/destroying objects when all you really wanna do is
> mutate an existing one a bit.

Right. But properly covering all this would require either a lot of
boilerplate code or some very tricky engine coding. BTW, I don't think
for GMP right now += modifies existing object. I guess it may be
possible to implement it the other way (not sure).
-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to