Am 29.08.2019 um 08:22 schrieb Alexandru Pătrănescu <dreal...@gmail.com>:
> When you write code, in a "productive" way that you mention, it's perfectly
> fine if you write it for you and for now.
> 
> But most often, we write code for the future generations of developers that
> could be less skilled, for the future you that might have less context.
> Also, code will evolve in time and bugs will eventually apear. In my
> opinion and maybe you can agree, some of these bugs could be avoided if
> variable definition before reading would be enforced.

... and that's why Zeev suggests a strict mode for people who want it that way.

Side-note: Which brings us back to the discussion about the downsides of 
language modes but as similar topics keep on popping up (although by the same 
people) you are slowly convincing me that going down that road is the best 
compromise.

> For most of the developers and businesses using PHP, that is a trade they
> want to enforce but can't or does not know how to do it.

That "most developers" is highly subjective depending on who you ask.
And yes, you can easily turn undefined variables into exceptions right now 
(even globally), just use

set_error_handler(function($errno, $errstr) {
        if (preg_match('/^Undefined variable/', $errstr))
                throw new Exception($errstr);
        return false;
}, E_NOTICE);

> I am for a default with more things enforced and maybe only allowed them
> based on declares, not the other way around.

Breaking code first and making migration harder instead of offering a clean 
migration path where developers opt-in to a new mode.

- Chris


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

Reply via email to