# order required

posted 8 years ago

Not sure I can explain in beginner's language, but basically it's all about order of operations and how stack-based computing works.

Here's what's going on:

Line 8: i is set to zero

Line 9: i = i++ + fl(i)

Evaluation order of the right-hand-side is left to right, so:

i++ : the value of i is pushed onto the stack, and then i is incremented by 1

i is now 1, and the stack is {0}

fl(i) is evaluated, with i equal to 1. This prints the "1," and then returns zero

The return value of the function is placed onto the stack

i is now 1, and the stack is {0, 0}

The addition operation is now evaluated, popping the first two values off of the stack and adding them together

0 and 0 are popped and added, resulting in a value of 0.

This value is pushed onto the stack as the total value of the right hand side.

The assignment then takes place, setting i to the value of the right hand side, which is 0

i is now 0, and the stack is irrelevant for our purposes.

We now print the value of i, which is 0.

End result is we've printed 1,0

Here's what's going on:

Line 8: i is set to zero

Line 9: i = i++ + fl(i)

Evaluation order of the right-hand-side is left to right, so:

i++ : the value of i is pushed onto the stack, and then i is incremented by 1

i is now 1, and the stack is {0}

fl(i) is evaluated, with i equal to 1. This prints the "1," and then returns zero

The return value of the function is placed onto the stack

i is now 1, and the stack is {0, 0}

The addition operation is now evaluated, popping the first two values off of the stack and adding them together

0 and 0 are popped and added, resulting in a value of 0.

This value is pushed onto the stack as the total value of the right hand side.

The assignment then takes place, setting i to the value of the right hand side, which is 0

i is now 0, and the stack is irrelevant for our purposes.

We now print the value of i, which is 0.

End result is we've printed 1,0

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.