Re: [PHP4BETA] New feature? (was: Is this a bug? Default params?)
| From: | Zeev Suraski | Date: | Tue, 10 Aug 1999 16:20:36 +0000 |
| Subject: | Re: [PHP4BETA] New feature? (was: Is this a bug? Default params?) | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-3289@lists.php.net to get a copy of this message | ||
At 15:59 10/08/99 , George Hartz wrote:
Samuel Liddicott wrote:We're thinking about this. Right now we don't have a very good way to implement it efficiently and nicely, so we'd rather not implement it at all. You could use the new PHP 4.0 notation of a default value of unset to a variable (function foo($foo=unset)) and then initialize it in the function with whatever value you have in mind if it is unset.A better option, given the assumption that it can't be changed, is to add a simple shorthand for it, something like this: $Username ?= $GLOBALS["login"]["username"]; Figuring that "?=" is semi-intuitive for "equals if not set" or something along those lines... Actually, now that I've said that, I really like the idea! :)I do too, very nice. But what I was saying is if we can type that as the first few lines of the function, why can't this JIT compiler pretent we did? JIT or not it should make no difference, as that code would be executed before any major conditionals. I don't know, maybe the Zend people can comment on this? There wasn't a clear explanation given why support for it was dropped, that was just my guess...
Nice idea of yours. Does that work for not-set, or for not-true?I guess you meant assign if not set, and not equal if not set..? I'm not sure adding another operator to the language for such a specific task is necessary, but we'll think about it some more. Zeev -- Zeev Suraski <zeev@zend.com> http://www.zend.com/ For a PGP public key, finger bourbon@netvision.net.il