On Mon, 21 Jan 2013 20:28:12 +0100, Anthony Ferrara <ircmax...@gmail.com>
wrote:
Gustavo
I've voted "No" due to concerns I mentioned in most part in IRC, but
which
I think should be here on the record. So my voting statement:
I'm voting against this proposal because I think the proposed syntax
strongly suggests that the property is bound to a specific type. This
has
several problems:
* It's a promise that's not guaranteed. As long as the getter is allowed
to reference the value of the variable can arbitrarily be changed to
whatever type. It may also be possible to do the same with
unserialization.
This is pretty easily solved by removing the ability to return a
reference from the getter when the shortcut syntax is used. In fact,
remove the
ability to set the body of a getter at all (it would only allow you to
specify the visibility. If you need references, you can't use this
syntax...
So now we have a new non-obvious special case for when a specific syntax
is used. So much for the equivalence argument. Allowing no getter body has
its own problems btw (lazy instantiation is no longer possible for
instance).
In any case, you leave unanswered other scenarios. Unserialization (and
remember there are various unserialization implementations)? Bug in the
setter (though I'm sure we could remove the ability to set the body as
well)? Now what's your solution? PHP should start policing the type of the
properties in all those scenarios? Maybe we should introduce Error
exceptions for those runtime field type mismatches, like the JVM does.
* The benefits are minimal. The only real benefit is cutting maybe two
lines of code in an indisputably common scenario.
Cutting two lines of code per instance. And considering that this is used
all the time, that can add up to some pretty significant (if not trivial)
boilerplate that's removed...
OK, so we disagree on the social value of removing, let's say 20 lines of
boilerplate.
But you still left unanswered my other concerns about the fact this
actually transmits the idea that PHP will enforce the type of a variable.
You may think that's not an issue; even then, I think this is a very
important change that merits more discussion. It's interesting that you
claim we "need a vision", but actually we could be about to start
introducing a fundamental change in the language in an incremental
backdoor fashion.
--
Gustavo Lopes
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php