On Sep 16, 2015, at 06:00, Rowan Collins <rowan.coll...@gmail.com> wrote: > > Absolutely. However, in order to need a dynamic check of variable existence, > you must also be using non-existence as a second sentinel value. You must be > saying "if the variable has never been assigned to, that means state X; if > it's been assigned a null value, that means state Y". My argument is that > using undefined variables like that is a bad choice of sentinel value, and if > you need more than one sentinel value in the first place, you probably need a > more complex data type (a struct-like object with separate state and value > properties, for instance).
I agree it’s bad practice to use “undefined” as a valid sentinel “value", but it’s something that needs to be checked in error handling sometimes. As an example, go back to template systems that just define a bunch of variables within the view’s scope: the view code needs to verify that it actually got needed variables before it uses them so that it can fail gracefully if it didn't. This is just defensive programming, not bad architecture (at least on the view’s part…), and while it can be avoided by having the template system use arrays or objects, if you don’t control the template system as the view writer, then you work with what you’re given. -Bob
signature.asc
Description: Message signed with OpenPGP using GPGMail