Any explaining ' following a name?

As came across the link below, is anyone very knowledgeable on c++ syntax so explaining the char ' following identifier name (e,g below and following link is the point) ?

int m;
int n' = m;
aappleby wrote:
a' means "the new value of a", but this syntax has no equivalent in real C++
So what source or who devise it and on which environment does that source mean to use it?
aappleby wrote that pseudocode for humans to read.
dealing with this kind of math you need to know how many values you have.

if you only have 2 values and simple states, it can be as easy as just using the combined assignment operators of c++, eg
x += 3; //x' = x+3 or the new value is the old value + 3, a simple sequence.

if its very complicated, you may need to actually make an xold and xnew variable, and some sequences want the previous N values, so you may need to keep a container of them all.
There is no way to make this automatic/syntactic in c++, it requires you as the programmer to keep track of old values that you need again in the code.

how you do it heavily depends on what exactly you need. that could mean static variables, containers of previous values, a custom object, combined operators, the call stack (recursive routines get a 'free' stack container you can use for this type of math), or whatever else.
I think the OP in that HN thread had rather unusual ideas.
It's pretty obvious that there's some kind of continuous loop that executes more or less the same steps every time, probably once per frame. A relatively simple way to solve this without inventing a new language would be to allocate your objects from a contiguous memory region and to clone it. Ideally you would also want to be able to track bytes or objects within that region that are modified. What you do then is simply write your code as on the post:
a_prime = b;
b_prime = a;
b = 7; //Error. Non-prime objects are read-only.
b_prime = a_prime; //Error. Prime-objects are write-only. Might be a bit tricky to enforce statically. 
At the end of one cycle through the loop, you swap both blocks of memory, such that b now refers to the memory b_prime previously referred to, and vice versa. You also copy from the now read-only block into the new write-only block to propagate changes; if you've kept track of dirty bytes you can do a minimal copy, but that may not be worthwhile if the memory blocks are really small.
Topic archived. No new replies allowed.