R
Rick C. Hodgin
Suppose that array int a[] contains { 1, 2, 3 }, and int i is 0.
After the execution of a = a[i++], what should be the values in a[]?
Why?
I think a[0] contains 'U' and a[1] contains 'B'.
UB3...
After a = a[i++], the correct answer will always be:
a[0] is 1
a[1] is 1
a[2] is 3
The reasoning is the sequence of operations:
// a = a[i++];
t1 = i; // i of "i++"
i = i + 1; // ++ of "i++"
t2 = a[t1]; // value of "a[i++]"
a = t2; // stored into "a"
If C does not define this behavior to be exactly this, shame on C.
RDC defines this behavior to be exactly this ... it is ALWAYS the order of
operations as is being computed. I provide a syntax to access in-flight
values as well, through casks, so their values can be referenced later on
in the same line.
a[ti] = a[((|ifp|ti||)i)++];
Make heads or tails of that without a GUI IDE! LOL! Here it is broken
out with spacing so you can see it more clearly:
a[ti] = a[( (|ifp|ti||) i) ++];
In this case, the original value of i is intercepted by the "in flight
parameter" cask, and it is assigned to the variable name "ti". This is
the value of i before it is incremented.
Casks allow code to be injected in the middle of otherwise syntatically
correct statements, yet without affecting their syntax, hence the RDC
mandate of things always being determined as per their order of operation.
http://www.visual-freepro.org/wiki/index.php/VXB++#Introducing_the_Cask
Best regards,
Rick C. Hodgin