www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - writef()

reply nascent <jesse.phillips eagles.ewu.edu> writes:
I created a stack using a LinkedList. This worked, but when testing it I 
found using,

writef("%s, %s, %s", stack.pop(), stack.pop(), stack.pop());

would present the stack as a fifo. I assume the results are because it 
is evaluating the arguments from right to left. Why?
Feb 23 2006
parent Oskar Linde <oskar.lindeREM OVEgmail.com> writes:
nascent wrote:
 I created a stack using a LinkedList. This worked, but when testing it I 
 found using,
 
 writef("%s, %s, %s", stack.pop(), stack.pop(), stack.pop());
 
 would present the stack as a fifo. I assume the results are because it 
 is evaluating the arguments from right to left. Why?

The order of evaluation is undefined. In this case, the ABI of your architecture says function arguments are pushed on the stack from the right to left. Therefore, it is also convenient for the compiler to evaluate them in that order. /Oskar
Feb 23 2006