Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-08 Thread Ashley Sheridan
On Wed, 2009-10-07 at 13:24 -0700, Tommy Pham wrote: From: tedd tedd.sperl...@gmail.com To: php-general@lists.php.net; a...@ashleysheridan.co.uk; Daevid Vincent dae...@daevid.com Sent: Wed, October 7, 2009 12:42:41 PM Subject: RE: [PHP] Whacky increment

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrea Giammarchi
So while we can debate computing considerations of today, tomorrow those will be less important. That was the point I was making. Why not focus on things that make significant difference and let the insignificant fade into history. I tendentiously focus on all things able to make, all

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread clancy_1
On Tue, 6 Oct 2009 12:15:54 -0400, tedd.sperl...@gmail.com (tedd) wrote: At 3:56 PM +0200 10/6/09, Andrea Giammarchi wrote: Does these behaves exactly? for($i=0; $i10; ++$i) for($i=0; $i10; $i++) different benchmarks showed ++$i is usually faster than $i++ Faster is a relative term that

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread tedd
At 6:15 PM -0700 10/6/09, Daevid Vincent wrote: Except that: $a = 123; $b = $a++; echo $b; //gives 123, not 124 as you logically expect it to and common sense would dictate, regardless of what KR or anyone else says. That's not the way I look at it. $b = $a++; means to me take the

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Ashley Sheridan
On Wed, 2009-10-07 at 08:54 -0400, tedd wrote: At 6:15 PM -0700 10/6/09, Daevid Vincent wrote: Except that: $a = 123; $b = $a++; echo $b; //gives 123, not 124 as you logically expect it to and common sense would dictate, regardless of what KR or anyone else says. That's not the way

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Jay Blanchard
Speaking of. [snip] -Original Message- From: Daevid Vincent [mailto:dae...@daevid.com] Sent: Tuesday, October 06, 2009 8:21 PM To: Jay Blanchard; 'Tommy Pham'; php-general@lists.php.net Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo HEY! Don't try

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Eddie Drapkin
On Tue, Oct 6, 2009 at 6:59 PM, Andrea Giammarchi an_...@hotmail.com wrote: So while we can debate computing considerations of today, tomorrow those will be less important. That was the point I was making. Why not focus on things that make significant difference and let the insignificant

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrea Giammarchi
I can write a test[1] that comes out with these results: String concat time: 0.18807196617126 String interpolation time: 0.14288902282715 Where using is faster than ' ! Common wisdom be damned! where is the test? ... and, is that kind of test where you put 12345678 variables inside a

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Tom Worster
just yesterday i was reading through this wonderful and very funny presentation: http://talks.php.net/show/froscon08/0 for me it really drove home the message (among others) that it makes sense to find out where the real gains can be made before investing your efforts in optimization. --

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrea Giammarchi
optimizations for you are a waste of time, I'll code like that. Have fun, I have wasted already too much time to taqlk about this silly stuff ... Best Regards Date: Wed, 7 Oct 2009 11:36:27 -0400 Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo From: f

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Eddie Drapkin
On Wed, Oct 7, 2009 at 11:36 AM, Tom Worster f...@thefsb.org wrote: just yesterday i was reading through this wonderful and very funny presentation:    http://talks.php.net/show/froscon08/0 for me it really drove home the message (among others) that it makes sense to find out where the real

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrea Giammarchi
This is a great talk / slideshow and definitely is a better way to drive home the point that PHP execution speed is relatively meaningless in terms of user experience. Well, at least up to a point... if it takes 0.1 per response, with 10 users will be 1 second to wait ... if it takes

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Jay Blanchard
[snip] ...flame... [/snip] Easy there hoss, no need to get worked up. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrea Giammarchi
Easy there hoss, no need to get worked up. In my opinion, being blamed for natural optimizations is the most ridiculous, hilarious, anti professional behavior I have ever seen ... but you are right, no need to get worked up, so have fun here. Regards

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread tedd
At 1:59 PM +0100 10/7/09, Ashley Sheridan wrote: On Wed, 2009-10-07 at 08:54 -0400, tedd wrote: At 6:15 PM -0700 10/6/09, Daevid Vincent wrote: Except that: $a = 123; $b = $a++; echo $b; //gives 123, not 124 as you logically expect it to and common sense would dictate, regardless of what KR

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrew Ballard
On Wed, Oct 7, 2009 at 3:42 PM, tedd tedd.sperl...@gmail.com wrote: However, what I find wacky about all of this is: for($i=1; $i=10; $i++) { echo($i); } and for($i=1; $i=10; ++$i) { echo($i); } Do exactly the same thing. I would have expected the first to

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Andrew Ballard
On Wed, Oct 7, 2009 at 3:58 PM, Andrew Ballard aball...@gmail.com wrote: On Wed, Oct 7, 2009 at 3:42 PM, tedd tedd.sperl...@gmail.com wrote: However, what I find wacky about all of this is: for($i=1; $i=10; $i++) { echo($i); } and for($i=1; $i=10; ++$i) { echo($i);

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-07 Thread Tommy Pham
From: tedd tedd.sperl...@gmail.com To: php-general@lists.php.net; a...@ashleysheridan.co.uk; Daevid Vincent dae...@daevid.com Sent: Wed, October 7, 2009 12:42:41 PM Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo At 1:59 PM +0100 10

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Bob McConnell
From: Joost [mailto:joost.t.h...@planet.nl] Daevid Vincent wrote: From: Ben Dunlap [mailto:bdun...@agentintellect.com] $a = $a++; I just think this is an ambiguous line of code that wasn't thought through. The presence of the postfix operator makes the result undefined, no matter what

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
It will be an accident if you get the results you are expecting. I agree that the operation is illogical, I must disagree about accidents. In PHP that operation will mean assign to the new $a variable the value returned from the other $a variable before the increment. There is no mystery

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Paul M Foster
On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell wrote: From: Joost [mailto:joost.t.h...@planet.nl] Daevid Vincent wrote: From: Ben Dunlap [mailto:bdun...@agentintellect.com] $a = $a++; I just think this is an ambiguous line of code that wasn't thought through. The

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Martin Scotta
On Tue, Oct 6, 2009 at 10:28 AM, Paul M Foster pa...@quillandmouse.comwrote: On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell wrote: From: Joost [mailto:joost.t.h...@planet.nl] Daevid Vincent wrote: From: Ben Dunlap [mailto:bdun...@agentintellect.com] $a = $a++; I

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
Does these behaves exactly? for($i=0; $i10; ++$i) for($i=0; $i10; $i++) different benchmarks showed ++$i is usually faster than $i++ In that loop case, yes, what's happen internally is exactly the same, $i will be from 0 to 9, in the other case obviously is not the same. but pre increment

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd
At 3:56 PM +0200 10/6/09, Andrea Giammarchi wrote: Does these behaves exactly? for($i=0; $i10; ++$i) for($i=0; $i10; $i++) different benchmarks showed ++$i is usually faster than $i++ Faster is a relative term that is becoming more meaningless each year. Considering that speed is

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
...@gmail.com Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo At 3:56 PM +0200 10/6/09, Andrea Giammarchi wrote: Does these behaves exactly? for($i=0; $i10; ++$i) for($i=0; $i10; $i++) different benchmarks showed ++$i is usually faster than $i++ Faster

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd
At 10:48 AM -0300 10/6/09, Martin Scotta wrote: No matter how silly it can looks like (a = a++) it is still completely valid code and it SHOULD run without problems. Yeah, it's a valid as: $a = $a; and does the same thing, which is nothing. If you want a statement that does something,

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Tommy Pham
- Original Message From: tedd tedd.sperl...@gmail.com To: Martin Scotta martinsco...@gmail.com; Paul M Foster pa...@quillandmouse.com Cc: php-general@lists.php.net Sent: Tue, October 6, 2009 11:08:14 AM Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd
At 11:11 AM -0700 10/6/09, Tommy Pham wrote: I find it interesting for a discussion to go on this long for something as $a = $a++; which should have never happened in the first place ;) Regards, Tommy Hey, we're programmers. We waste time for a living. Cheers, tedd -- ---

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Jay Blanchard
[snip] I find it interesting for a discussion to go on this long for something as $a = $a++; [/snip] You think that is interesting? Start a conversation about these {} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Ashley Sheridan
On Tue, 2009-10-06 at 13:34 -0500, Jay Blanchard wrote: [snip] I find it interesting for a discussion to go on this long for something as $a = $a++; [/snip] You think that is interesting? Start a conversation about these {} Now they actually make sense! I've used those as

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Israel Ekpo
On Tue, Oct 6, 2009 at 2:34 PM, Jay Blanchard jblanch...@pocket.com wrote: [snip] I find it interesting for a discussion to go on this long for something as $a = $a++; [/snip] You think that is interesting? Start a conversation about these {} -- PHP General Mailing List

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Daniel Brown
On Tue, Oct 6, 2009 at 14:46, Israel Ekpo israele...@gmail.com wrote: Speaking of starting a conversation, what do you think about the goto construct introduced just recently? Better yet: what do you all think of folks hijacking threads? -- /Daniel P. Brown daniel.br...@parasane.net ||

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
Furthermore, the amount of time micro-optimization takes up (going through old code, I mean) could be better spent doing something that actually does increase your performance, like implementing a search engine or memcached. Going forward, if you're aware that ++i and i++ are the same for

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
ah ah ah that's for sure, I've never said that is correct, I said that is illogical ;-) Subject: RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo Date: Tue, 6 Oct 2009 12:46:36 -0500 From: jblanch...@pocket.com To: an_...@hotmail.com; tedd.sperl...@gmail.com; php

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
Eddie: And thanks for supporting my point. so you think as well that 3 characters, written like this i++, in a careless way, or like this ++i, make the difference about time spent to develop ... interesting Regards

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
Speaking of starting a conversation, what do you think about the goto construct introduced just recently? if used properly, could avoid recursion, and speed up operations ... there is nothing wrong with goto, everything we write on lowest level is a jump in the memory (as goto is a jump in

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Andrea Giammarchi
if used properly, could avoid recursion, and speed up operations ... there is nothing wrong with goto, everything we write on lowest level is a jump in the memory (as goto is a jump in the code flow) ++goto ... and not goto++ I forgot, I have always used goto in Batch script, which

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread clancy_1
On Tue, 6 Oct 2009 14:08:14 -0400, tedd.sperl...@gmail.com (tedd) wrote: At 10:48 AM -0300 10/6/09, Martin Scotta wrote: No matter how silly it can looks like (a = a++) it is still completely valid code and it SHOULD run without problems. Yeah, it's a valid as: $a = $a; and does the same

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd
At 1:09 AM +0200 10/7/09, Andrea Giammarchi wrote: Eddie: And thanks for supporting my point. so you think as well that 3 characters, written like this i++, in a careless way, or like this ++i, make the difference about time spent to develop ... interesting No, just the opposite. It

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread tedd
At 10:20 AM +1100 10/7/09, clanc...@cybec.com.au wrote: On Tue, 6 Oct 2009 14:08:14 -0400, tedd.sperl...@gmail.com (tedd) wrote: At 10:48 AM -0300 10/6/09, Martin Scotta wrote: No matter how silly it can looks like (a = a++) it is still completely valid code and it SHOULD run without

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Daevid Vincent
-Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: Tuesday, October 06, 2009 6:28 AM To: php-general@lists.php.net Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo On Tue, Oct 06, 2009 at 08:51:17AM -0400, Bob McConnell

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Daevid Vincent
HEY! Don't try to hijack my astonishingly long-running thread! Start your own Jay. ;-} -Original Message- From: Jay Blanchard [mailto:jblanch...@pocket.com] Sent: Tuesday, October 06, 2009 11:34 AM To: Tommy Pham; php-general@lists.php.net Subject: RE: [PHP] Whacky increment

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-06 Thread Robert Cummings
Andrea Giammarchi wrote: if used properly, could avoid recursion, and speed up operations ... there is nothing wrong with goto, everything we write on lowest level is a jump in the memory (as goto is a jump in the code flow) ++goto ... and not goto++ I forgot, I have always used goto in

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread Ralph Deffke
Ben, might be intersting to consider that in ur c axample u r working with a pure memory position, while php works with references. thry it with pointers it I'm pretty shure u get the same result as in PHP. I'm not shure, because I don't work in perl, but doesn't per work on references as well ?

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread tedd
At 2:01 PM -0700 10/2/09, Daevid Vincent wrote: Why would you EVER want $num = $num++; to give you back the value you already had? Even if we did $foo = $bar++; I would still logically (and common sensely) expect $foo to be the increment of $bar! You are right -- one should never structure a

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread tedd
At 5:12 PM -0400 10/2/09, Robert Cummings wrote: Daevid Vincent wrote: ?PHP $num = 123; $num = $num++; print $num; //this prints 123 and not 124 ?!! $num = 123; $num = ++$num; print $num; //this prints 124 as expected $num = 123; $num++; print $num; //this prints 124 as expected $num =

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread tedd
At 2:28 PM -0700 10/2/09, Daevid Vincent wrote: My problem isn't with $foo++ vs ++$foo per say. I use pre/post all the time. My issue is that I see no reason to do the ASSIGNMENT FIRST and THEN INCREMENT. I see your point exactly. The problem is with the statement of: $num = $num++; That

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread tedd
At 2:53 PM -0700 10/2/09, Ben Dunlap wrote: $a = 2; $a = $a++; echo $a; Honestly I think the only reason anyone would write an expression like that is either to fake out the compiler or because they don't properly understand the use of a unary operator. Or rather, of the

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread tedd
At 5:42 PM -0400 10/2/09, Daniel Brown wrote: If you were to use $num++, it would echo out the current number, THEN increment the value. In this example, it increments the value, THEN echoes it out. The placement of the signs (plus or minus) is the giveaway: if it's before the variable,

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread Daniel Brown
On Sat, Oct 3, 2009 at 10:49, tedd tedd.sperl...@gmail.com wrote: That's absolutely true. The problem here is in the statement of: $num = $num++; Yeah, I understood Daevid's email a bit better *after* I sent mine. Then I was hoping no one noticed. -- /Daniel P. Brown

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread Andrea Giammarchi
... and, in fact, that /is/ how C behaves. The following code: int a = 2; a = a++; printf(a = [%d]\n, a); Will output a = [3]. At least on Ubuntu 9 using gcc 4.3.3. So I retract my initial terse reply and apologize for misunderstanding your question. Ben It's not that difficult

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-03 Thread Lupus Michaelis
Ben Dunlap wrote: ... and, in fact, that /is/ how C behaves. The following code: No, that's implementation's behaviour. AFAIK, the normative document give to compiler the behaviour implementation. So, it can do optimization, that gives strange behaviour for a people how think increment

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Ben Dunlap
Can someone PLEASE explain why the developers of PHP chose this seemingly whacky logic? It mimicks C. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Robert Cummings
Daevid Vincent wrote: ?PHP $num = 123; $num = $num++; print $num; //this prints 123 and not 124 ?!! $num = 123; $num = ++$num; print $num; //this prints 124 as expected $num = 123; $num++; print $num; //this prints 124 as expected $num = 123; print $num++; //this prints 123 and not 124 ?!!

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Tommy Pham
- Original Message From: Ben Dunlap bdun...@agentintellect.com To: Daevid Vincent dae...@daevid.com Cc: php-general@lists.php.net Sent: Fri, October 2, 2009 2:06:47 PM Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo Can someone PLEASE explain why

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Daevid Vincent
-Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Friday, October 02, 2009 2:12 PM To: Daevid Vincent Cc: php-general@lists.php.net Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo Daevid Vincent wrote: ?PHP $num = 123

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Ben Dunlap
My issue is that I see no reason to do the ASSIGNMENT FIRST and THEN INCREMENT. That's just counter intuitive. In the case of $foo = $num++, everything to the right of the = should be computed FIRST and THEN handed off to the left side. This particular expression (and I'm unaware of any

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Daniel Brown
On Fri, Oct 2, 2009 at 17:28, Daevid Vincent dae...@daevid.com wrote: Personally I've never (in almost 20 years) done an assignment like $foo = $foo++ as I always use just $foo++ or $foo += 1 or something, hence the reason today is the day a co-worker stumbled upon this and was as confused as

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Daniel Brown
On Fri, Oct 2, 2009 at 17:42, Daniel Brown danbr...@php.net wrote:     but rather by something just slightly more advanced: ?php $num = file_get_contents('visitcount.txt'); if(isset($_GET['countme'])) {    echo You are visitor #.++$num.br /\n;    file_put_contents($num); } ?

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Ben Dunlap
On Fri, Oct 2, 2009 at 2:37 PM, Ben Dunlap bdun...@agentintellect.com wrote: My issue is that I see no reason to do the ASSIGNMENT FIRST and THEN INCREMENT. That's just counter intuitive. In the case of $foo = $num++, everything to the right of the = should be computed FIRST and THEN handed

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Daevid Vincent
-Original Message- From: Ben Dunlap [mailto:bdun...@agentintellect.com] Sent: Friday, October 02, 2009 2:58 PM To: php-general@lists.php.net; Daevid Vincent Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo mind-blowing. What the heck /is/ supposed

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Mari Masuda
On Oct 2, 2009, at 15:22, Daevid Vincent wrote: -Original Message- From: Ben Dunlap [mailto:bdun...@agentintellect.com] Sent: Friday, October 02, 2009 2:58 PM To: php-general@lists.php.net; Daevid Vincent Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Ben Dunlap
       int a = 2;        b = a++;        printf(b = [%d]\n, b); b would be 2 when printed.  However, after the second line (b = a++;) finished executing, a would then be 3. Sure, but that code is perfectly clear. It's the odd special case where you assign the variable to itself, that's

RE: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Joost
Daevid Vincent wrote: -Original Message- From: Ben Dunlap [mailto:bdun...@agentintellect.com] Sent: Friday, October 02, 2009 2:58 PM To: php-general@lists.php.net; Daevid Vincent Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo mind-blowing. What