Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Wed, 16 Sep 2015 17:06:31 +0000
Subject: Re: PHP 7.1 - Address PHPSadness #28?
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-88250@lists.php.net to get a copy of this message
On Sep 16, 2015, at 06:00, Rowan Collins <rowan.collins@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

Attachment: [application/pgp-signature] Message signed with OpenPGP using GPGMail signature.asc
« previous php.internals (#88250) next »