[PHP-DEV] Re: ++$i++ (was Re: [PHP-DEV] call_builtin_function_array() possible?)

2001-01-10 Thread Andrei Zmievski

On Wed, 10 Jan 2001, Cynic wrote:
> I recently needed to process every other element of a 
> numerically indexed array. 
> for( $i = 0 ; $i < count( $a ) ; $x = $a[ ++$i++ ] ) 
> would have saved me one statement. I had to use 
> for( $i = 0 ; $i < count( $a ) ; $x = $a[ $i++ ] , $i++ ) 
> I know, this is an 'issue' so tiny I can laugh at it, but 
> anyway...

You know, this is not C, you are not going to save 0.2 microseconds of
execution time by writing obscure code like this. Even in C this is not
encouraged.

-Andrei

"The secret of flying is to throw yourself
at the ground, and miss." -- Douglas Adams

-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Re: ++$i++ (was Re: [PHP-DEV] call_builtin_function_array() possible?)

2001-01-10 Thread Cynic

yes, I meant: "increment $i, assign $a[ $i ] to $x, and then 
increment once more. 

ok, then, let's forget it.

At 14:07 10.1. 2001, Zeev Suraski wrote the following:
-- 
>At 15:01 10/1/2001, Cynic wrote:
>>would have saved me one statement. I had to use
>>for( $i = 0 ; $i < count( $a ) ; $x = $a[ $i++ ] , $i++ )
>
>This is a very weird and uncommon piece of code.  If it's indeed correct (which I 
>doubt - do you want to increment it by two?) then a more common & understandable way 
>to write it would have been
>$x = $a[$i], $i+=2.
>
>Saving an extra expression by adding the ultra-obscure ++$i++ is a definite 'no'.  
>There's no logical behavior that would be both pre- and post-increment, which is 
>implied by this weird notation...
>
>Zeev
>
>>I know, this is an 'issue' so tiny I can laugh at it, but
>>anyway...
>>
>>At 13:49 10.1. 2001, Zeev Suraski wrote the following:
>>--
>>>Could you explain how this construct is useful?  I can't think of any real world 
>situation in which it's useful or even remotely makes sense.  What would it even do?  
>Remember, an expression has only one value.
>>>
>>>Zeev
>>>
>>>At 14:51 10/1/2001, Cynic wrote:
Well, this would be probably completely useless (at least I
can't think of a meaningful use of this right now), but... is
there a reason this can't be implemented in PHP? I know, time
is a very precious commodity, and I wouldn't ask (or suggest)
for an implementation of this if it would require extra work
besides making pre- and post- increment / decrement in one
statement. But if allowing ++$i++ (which I definitely consider
useful) makes ++$i-- possible without additional effort, why
disable it? It's possible to write completely useless junk
software without this feature too.

Lack of knowledge of C prevents me from going to try and do
this myself.


At 21:51 9.1. 2001, Hartmut Holzgraefe wrote the following:
--
>Cynic wrote:
>>
>> At 21:16 9.1. 2001, Andrei Zmievski wrote the following:
>> >What color is the sky on your planet? :)
>>
>> I don't know, haven't checked for some time now. :)
>> But seriously: I'm not familiar with C, nor the way this stuff
>> is implemented in PHP, however, whether the sky here is blue or
>> pink doesn't mean I think this wouldn't be useful.
>
>and what's next?
>
>++$i-- ???
>
>--
>Hartmut Holzgraefe  [EMAIL PROTECTED]  http://www.six.de +49-711-99091-77
>
>--
>PHP Development Mailing List 
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
--end of quote--




Cynic:

A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.

[EMAIL PROTECTED]



--
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
>>>
>>>--
>>>Zeev Suraski <[EMAIL PROTECTED]>
>>>CTO &  co-founder, Zend Technologies Ltd. http://www.zend.com/
>>>
>>--end of quote--
>>
>>
>>
>>
>>Cynic:
>>
>>A member of a group of ancient Greek philosophers who taught
>>that virtue constitutes happiness and that self control is
>>the essential part of virtue.
>>
>>[EMAIL PROTECTED]
>
>--
>Zeev Suraski <[EMAIL PROTECTED]>
>CTO &  co-founder, Zend Technologies Ltd. http://www.zend.com/
>
--end of quote-- 




Cynic:

A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.

[EMAIL PROTECTED]



-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Re: ++$i++ (was Re: [PHP-DEV] call_builtin_function_array() possible?)

2001-01-10 Thread Zeev Suraski

At 15:01 10/1/2001, Cynic wrote:
>would have saved me one statement. I had to use
>for( $i = 0 ; $i < count( $a ) ; $x = $a[ $i++ ] , $i++ )

This is a very weird and uncommon piece of code.  If it's indeed correct 
(which I doubt - do you want to increment it by two?) then a more common & 
understandable way to write it would have been
$x = $a[$i], $i+=2.

Saving an extra expression by adding the ultra-obscure ++$i++ is a definite 
'no'.  There's no logical behavior that would be both pre- and 
post-increment, which is implied by this weird notation...

Zeev

>I know, this is an 'issue' so tiny I can laugh at it, but
>anyway...
>
>At 13:49 10.1. 2001, Zeev Suraski wrote the following:
>--
> >Could you explain how this construct is useful?  I can't think of any 
> real world situation in which it's useful or even remotely makes 
> sense.  What would it even do?  Remember, an expression has only one value.
> >
> >Zeev
> >
> >At 14:51 10/1/2001, Cynic wrote:
> >>Well, this would be probably completely useless (at least I
> >>can't think of a meaningful use of this right now), but... is
> >>there a reason this can't be implemented in PHP? I know, time
> >>is a very precious commodity, and I wouldn't ask (or suggest)
> >>for an implementation of this if it would require extra work
> >>besides making pre- and post- increment / decrement in one
> >>statement. But if allowing ++$i++ (which I definitely consider
> >>useful) makes ++$i-- possible without additional effort, why
> >>disable it? It's possible to write completely useless junk
> >>software without this feature too.
> >>
> >>Lack of knowledge of C prevents me from going to try and do
> >>this myself.
> >>
> >>
> >>At 21:51 9.1. 2001, Hartmut Holzgraefe wrote the following:
> >>--
> >>>Cynic wrote:
> 
>  At 21:16 9.1. 2001, Andrei Zmievski wrote the following:
>  >What color is the sky on your planet? :)
> 
>  I don't know, haven't checked for some time now. :)
>  But seriously: I'm not familiar with C, nor the way this stuff
>  is implemented in PHP, however, whether the sky here is blue or
>  pink doesn't mean I think this wouldn't be useful.
> >>>
> >>>and what's next?
> >>>
> >>>++$i-- ???
> >>>
> >>>--
> >>>Hartmut Holzgraefe  [EMAIL PROTECTED]  http://www.six.de +49-711-99091-77
> >>>
> >>>--
> >>>PHP Development Mailing List 
> >>>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>For additional commands, e-mail: [EMAIL PROTECTED]
> >>>To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >>--end of quote--
> >>
> >>
> >>
> >>
> >>Cynic:
> >>
> >>A member of a group of ancient Greek philosophers who taught
> >>that virtue constitutes happiness and that self control is
> >>the essential part of virtue.
> >>
> >>[EMAIL PROTECTED]
> >>
> >>
> >>
> >>--
> >>PHP Development Mailing List 
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >--
> >Zeev Suraski <[EMAIL PROTECTED]>
> >CTO &  co-founder, Zend Technologies Ltd. http://www.zend.com/
> >
>--end of quote--
>
>
>
>
>Cynic:
>
>A member of a group of ancient Greek philosophers who taught
>that virtue constitutes happiness and that self control is
>the essential part of virtue.
>
>[EMAIL PROTECTED]

--
Zeev Suraski <[EMAIL PROTECTED]>
CTO &  co-founder, Zend Technologies Ltd. http://www.zend.com/


-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Re: ++$i++ (was Re: [PHP-DEV] call_builtin_function_array() possible?)

2001-01-10 Thread Cynic

I recently needed to process every other element of a 
numerically indexed array. 
for( $i = 0 ; $i < count( $a ) ; $x = $a[ ++$i++ ] ) 
would have saved me one statement. I had to use 
for( $i = 0 ; $i < count( $a ) ; $x = $a[ $i++ ] , $i++ ) 
I know, this is an 'issue' so tiny I can laugh at it, but 
anyway...

At 13:49 10.1. 2001, Zeev Suraski wrote the following:
-- 
>Could you explain how this construct is useful?  I can't think of any real world 
>situation in which it's useful or even remotely makes sense.  What would it even do?  
>Remember, an expression has only one value.
>
>Zeev
>
>At 14:51 10/1/2001, Cynic wrote:
>>Well, this would be probably completely useless (at least I
>>can't think of a meaningful use of this right now), but... is
>>there a reason this can't be implemented in PHP? I know, time
>>is a very precious commodity, and I wouldn't ask (or suggest)
>>for an implementation of this if it would require extra work
>>besides making pre- and post- increment / decrement in one
>>statement. But if allowing ++$i++ (which I definitely consider
>>useful) makes ++$i-- possible without additional effort, why
>>disable it? It's possible to write completely useless junk
>>software without this feature too.
>>
>>Lack of knowledge of C prevents me from going to try and do
>>this myself.
>>
>>
>>At 21:51 9.1. 2001, Hartmut Holzgraefe wrote the following:
>>--
>>>Cynic wrote:

 At 21:16 9.1. 2001, Andrei Zmievski wrote the following:
 >What color is the sky on your planet? :)

 I don't know, haven't checked for some time now. :)
 But seriously: I'm not familiar with C, nor the way this stuff
 is implemented in PHP, however, whether the sky here is blue or
 pink doesn't mean I think this wouldn't be useful.
>>>
>>>and what's next?
>>>
>>>++$i-- ???
>>>
>>>--
>>>Hartmut Holzgraefe  [EMAIL PROTECTED]  http://www.six.de +49-711-99091-77
>>>
>>>--
>>>PHP Development Mailing List 
>>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>For additional commands, e-mail: [EMAIL PROTECTED]
>>>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>>--end of quote--
>>
>>
>>
>>
>>Cynic:
>>
>>A member of a group of ancient Greek philosophers who taught
>>that virtue constitutes happiness and that self control is
>>the essential part of virtue.
>>
>>[EMAIL PROTECTED]
>>
>>
>>
>>--
>>PHP Development Mailing List 
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>--
>Zeev Suraski <[EMAIL PROTECTED]>
>CTO &  co-founder, Zend Technologies Ltd. http://www.zend.com/
>
--end of quote-- 




Cynic:

A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.

[EMAIL PROTECTED]



-- 
PHP Development Mailing List 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]