ifsetor(), goto, 5.x, my two cents
| From: | Noah Botimer | Date: | Wed, 08 Jun 2005 22:20:46 +0000 |
| Subject: | ifsetor(), goto, 5.x, my two cents | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-16569@lists.php.net to get a copy of this message | ||
Hello all,
Now that my PHP-DEV imap folder has cooled off a bit, I'd like to chime in briefly on ifsetor() and goto.
As far as ifsetor() goes, I like the concept. I would, however, suggest a specific behavior and a name change. I do a lot of database code and use things like ISNULL() and COALESCE() to translate NULL values to 0's, placeholder strings, etc. ISNULL() typically provides a check of one value, and acts just as a ternary operation:
value = check ? check : alternative;
while COALESCE() usually returns the first non-null parameter, or NULL if all are parameters are NULL.
Since PHP already supports arbitrary/optional parameters natively, I think a single coalesce() function would be a very reasonable extension that would behave in an understandable and desirable manner (with a name that matches at least some common usage).
As for goto, we may be fighting over nothing. There is a lot of abuse that may be done with goto, as has been illustrated but, with a couple of sensible limitations, the horrific problems should be averted. It also seems to me that GOTO is far less often mentioned to beginners as a means of flow control since line-numbered BASIC has faded. People who get into trouble with it will likely have a good reason to be playing with fire. I say: put it in, label it dangerous, and let the developers decide if it's right for them.
Thanks,
-Noah Botimer