Hello, maybe I will show up. But otherwise I don’t even know how to describe such a question.
We have a giant function for calculating a bunch of values. At the beginning of the function, many constants and values are accepted, but one of the variables will be calculated closer to the end of the function. It turns out that it is unknown at the beginning. The unknown of this number at the time of passing the function does not affect its calculation. but many variables at the moment of its declaration and its calculation are calculated taking into account this variable, but we obtain its value only at the end of the function. The question is, we need to get the value of the variable at the beginning, which is calculated approximately at the end of the function. Everything happens in the limit of a single function block. There is such a thing in the swift, we write the code and oops we need to jump over a bunch of lines (I don’t remember how it gets called "I would be grateful if someone reminds me"), we write the transition command to the code key (B), marking where in the code this place is. And we go to the place with the key (B), if we don’t need to go back, we don’t write anything, and if we need to go back, we write this code to go to the key (A), but also prescribe the place where this key is (A). If you specify it before jumping to the key B or do not close the transition code from its pass to the transition line to the key (B), the program will open. At the same time, all changes of variables, those that are not inside the internal blocks, are declared in the beginning in the memory. Roughly speaking, we run everything we calculate, then we put the transition team, so as not to pass twice, close it with an if, to get there once. We return to the beginning, already with the knowledge of this variable, and calculate everything anew.
How to implement it in C ++.
gotobut this is not welcome. - pavel