Robert Williams wrote on 16/09/2015 18:27:
an even more common scenario is config files that are supposed to just define a bunch of standalone variables, which is a very common pattern. If you’re writing code that relies on those variables, or you’re writing the code that’s supposed to pull that file in to begin with, it’s smart to make sure all the variables actually got set, and if not, display an error to the user to go fix the config. Sometimes, isset() works for this if combined with a null check, but it fails in cases where null is an acceptable value.

OK, that's a reasonable example, though I'd say it's still very much an edge case. It requires the following to all be true:

- the config file defines bare variables rather than array or object keys
- the variable in question has null as a valid value
- the variable in question is mandatory, with no default value

I will admit that exists($foo) would be useful in that situation, but it doesn't feel to me like such a common or useful scenario that it justifies the language changing to suit that design, rather than the design changing to suit the language.

Regards,
--
Rowan Collins

Reply via email to