Re: [PHP-DEV] Construct Request

2004-04-16 Thread Sascha Schumann
On Fri, 16 Apr 2004, Andi Gutmans wrote: At 02:21 PM 4/15/2004 -0400, Sean Coates wrote: Andi Gutmans wrote: It could be implemented but I don't see the big advantage over $bar ? 0 : $base It's one character... oes to GCC and its C extension). $bar ? : $baz; If $bar evaluates to

[PHP-DEV] Construct Request

2004-04-15 Thread Jason Garber
Hello Internals team, Thank you for taking a moment to evaluate a serious request by a serious php developer that is responsible for a development company of 15 employees. In order to keep our code as clean and error free as possible, we opt to develop in the E_ALL error mode, and

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Ilia Alshanetsky
I am not sure what would be the best name for such an engine construct or a function, but the idea itself is good (IMHO). It would certainly make it easier to write safer notice free code. Ilia -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit:

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Sascha Schumann
That is basically the same idea once proposed as extending the ternary operator (credit goes to GCC and its C extension). $bar ? : $baz; If $bar evaluates to true, the expression evaluates to $bar or to 0, respectively. - Sascha -- PHP Internals - PHP Runtime

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Sean Coates
Is there a good reason to NOT implement this? If not, I'm +1 on that (if I carry ANY weight at all (-: ) BC isn't an issue, and it would be a very useful feature, IMHO.. S Sascha Schumann wrote: That is basically the same idea once proposed as extending the ternary operator (credit goes

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Andi Gutmans
It could be implemented but I don't see the big advantage over $bar ? 0 : $base It's one character... At 02:09 PM 4/15/2004 -0400, Sean Coates wrote: Is there a good reason to NOT implement this? If not, I'm +1 on that (if I carry ANY weight at all (-: ) BC isn't an issue, and it would be a very

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Jason Garber
The best functionality would be for it to return the value, not re-assign it. Many of the things being talked about would modify the sent parameter, rather than return selected value. For instance (using the isset_or_default()) call: $nCustID = (int) isset_or_default($_POST['CUST_ID'], 0);

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Hartmut Holzgraefe
Sascha Schumann wrote: That is basically the same idea once proposed as extending the ternary operator (credit goes to GCC and its C extension). $bar ? : $baz; yes, that looks like the way it should look like, and the danger of newbees abusing it would be way lower than with a function

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Derick Rethans
On Thu, 15 Apr 2004, Jason Garber wrote: $_POST['CUST_ID'] = (int) isset_or_default($_POST['CUST_ID'], 0); I agree that it would be helpful not to evaluate the second parameter unless needed, which is why I originally proposed a language construct. You'll need something more clever, because

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Jason Garber
Hi Derick, I see. I was basing the spec on the functionality of isset() which does not (obviously) throw an E_NOTICE when you pass an undefined variable to it. However, do you see any reason that this would not reliably work? function setor($param, $default) { return (isset($param) ?

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Derick Rethans
On Thu, 15 Apr 2004, Jason Garber wrote: I see. I was basing the spec on the functionality of isset() which does not (obviously) throw an E_NOTICE when you pass an undefined variable to it. However, do you see any reason that this would not reliably work? I wrote this (I underlined the

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Jason Garber
I wrote this (I underlined the relevant parts for you): You'll need something more clever, because an undefined key 'CUST_ID' in $_POST['CUST_ID'] will strill throw a Consider this: --- ?php error_reporting(E_ALL); function setor($param, $default) {

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Todd Ruth
You can avoid the E_NOTICE using a reference, but it can have undesired side effects. For example, if you pass $x[5] by reference (whether to an internal function or a user defined function), $x[5] will be created and set to NULL. To avoid this side-effect, don't use the reference and instead

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Wez Furlong
+1 for the GCC style syntax. --Wez. - Original Message - From: Hartmut Holzgraefe [EMAIL PROTECTED] To: Sascha Schumann [EMAIL PROTECTED] Cc: Ilia Alshanetsky [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Thursday, April 15, 2004 8:47 PM Subject: Re: [PHP-DEV] Construct Request Sascha

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Marcus Boerger
Hello Derick, Thursday, April 15, 2004, 10:07:01 PM, you wrote: On Thu, 15 Apr 2004, Jason Garber wrote: I see. I was basing the spec on the functionality of isset() which does not (obviously) throw an E_NOTICE when you pass an undefined variable to it. However, do you see any reason that

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Sean Coates
Jason Garber wrote: function setor($param, $default) { return (isset($param) ? $param : $default); } I tested it on 4.3.4 and 5.0 RC1, and it worked. Is passing an undefined variable as a reference parameter a legal thing to do in PHP? That bring up an interesting point:

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Andrey Hristov
Sean Coates wrote: Jason Garber wrote: function setor($param, $default) { return (isset($param) ? $param : $default); } I tested it on 4.3.4 and 5.0 RC1, and it worked. Is passing an undefined variable as a reference parameter a legal thing to do in PHP? That bring up an interesting

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Andi Gutmans
At 02:21 PM 4/15/2004 -0400, Sean Coates wrote: Andi Gutmans wrote: It could be implemented but I don't see the big advantage over $bar ? 0 : $base It's one character... oes to GCC and its C extension). $bar ? : $baz; If $bar evaluates to true, the expression evaluates to $bar or to

Re: [PHP-DEV] Construct Request

2004-04-15 Thread Jason Garber
Hello, Let me make an attempt to clarify what I originally requested. -- A function/construct named setor() modeled after isset(), which takes 2 parameters: parameter 1, the variable in question parameter 2, the default value if(isset($parameter1)) return $parameter1; else return