Errors, bugs, questions - page 2209

 
Slava:

And because your examples are purely theoretical. They are purely for students. No programmer in his/her right mind would put such things into production.

Postfix and prefix increments and decrements are actually used first of all in loops. And they are called increments and decrements!

Here are some examples

и

If you claim that prefix and postfix operations work alike, then flag in the hand and drum on your neck.

In the case of prefix increment, you will get an uninitialized null array element and an array out of range error at the last iteration.

Maybe your high mind doesn't get it, I'll repeat my question once again.

а при чем тут array[++i]=i и array[i++]=i, как я могу сравнить то, чего не было в беседе...

Is the highlighted one hard for you to see?

Now to the point, why in the example that appears in the conversation, the result in mql == 12 and it doesn't matter whether it was made out of hand or not, when there is a difference in postfix and prefix operations, the result should be == 13

ps. and i'm not making a statement, because now i checked and really do postfix and prefix now have a difference, but my question above gives reason to believe that the ambiguities in the language at compile time apparently enough and before you pounce on someone in the branch, deal with these UB, we are not at fault here

By the way, I see the help has already been tinkered with )).

 
Konstantin:

Maybe your high mind doesn't get it, I'll repeat my question again.

you don't understand the highlighted part?

now to the point, why in the example that appears in the conversation, the result in mql == 12 and it doesn't matter whether it's made out of hand or not, when the difference in postfix and prefix operations, the result should be == 13

ps. and i'm not making a statement, because now i checked and really do postfix and prefix now have a difference, but my question above gives reason to believe that the ambiguities in the language at compile time apparently enough and before you pounce on someone in the branch, deal with these UB, we are not at fault here

By the way, the help looks like it's been shoveled around).

Don't be snarky.

Who says the results have to be 13? Again, results with side-effects are highly dependent on optimization. Even if you don't apply optimization to such an expression, an implementation comes into play - a change in the variable's value either immediately after using it or after calculating the expression. Which implementation is correct?

We're not going to deal with UB, that's undefined, and clearly wrote: "Do not do that.

Where has the help been copied? I have opened MQL5 reference from MetaEditor build 1755 dated January 18. It says the same thing

Important Notice

int i=5;
int k = i++ + ++i;

Computational problems may occur while moving the above expression from one programming environment to another one (for example, from Borland C++ to MQL5). In general, the order of computations depends on the compiler implementation. In practice, there are two ways to implement the post-decrement:

  1. The post-decrement (post-increment) is applied to the variable after calculating the whole expression.
  2. The post-decrement (post-increment) is applied to the variable immediately at the operation.

Currently the first way of post-decrement calculation is implemented in MQL5. But even knowing this peculiarity, it is not recommended to experiment with its use.


Your original statement was that there is no difference between postfix and prefix operations. Isn't there?

 
Slava:

Don't be flippant.

Who says the results have to be 13? Again, results with side-effects are highly dependent on optimization. Even if you don't apply optimization to such an expression, an implementation comes into play - a change in the variable's value either right after you use it or after calculating the expression. Which implementation is correct?

We are not going to deal with UB, that's why it is undefined, and we explicitly said "don't do that".

Where did you go in the reference? I have opened MQL5 reference from MetaEditor build 1755 dated January 18. It says the same thing

Important Notice

int i=5;
int k = i++ + ++i;

Computational problems may occur while moving the above expression from one programming environment to another one (for example, from Borland C++ to MQL5). In general, the order of computations depends on the compiler implementation. In practice, there are two ways to implement the post-decrement:

  1. The post-decrement (post-increment) is applied to the variable after calculating the whole expression.
  2. The post-decrement (post-increment) is applied to the variable immediately at the operation.

Currently the first way of post-decrement calculation is implemented in MQL5. But even knowing this peculiarity, it is not recommended to experiment with its use.


Your original statement was that there is no difference between postfix and prefix operations. Isn't it so?

I'm not being cheeky, note where you started the dialogue, i.e. I had to execute a code i didn't even know about - super

as for the help - yes, it was overhauled because when I was dealing (about two years ago) with postfix and prefix operations in mql, I obviously do not remember this material now

so, the subject was closed, and we introduced this difference and did it well, but you have to warn that you're changing

 
. ... Rick D. ... .:
Please advise on partial position closing, account type RETAIL_HEDGING. For example, I close half of a position in Expert Advisor and a new order with a smaller lot should open automatically. So, at what point the new order is guaranteed to be in the terminal? Do I understand correctly that it does not have to appear immediately after the PositionClosePartial and we have to catch it somewhere in OnTrade?
Let me try to answer my own question. When calling the PositionClosePartial, the ticket of a closed order will return to CTrade::ResultOrder(), and the position ticket remains the same, but the position itself will have a smaller lot. Let's try to conclude that the call of PositionClosePartial leads to a synchronous decrease of the position and change of the order history in one transaction.
 

What the hell is that thing?

2018.05.15 12:50:04.594 Pred_Find (GBPUSD,M1)   Access violation at 0x000000013F1C4945 read to 0xFFFFFFFFFFFFFFFF
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48A0 48895 C2418        mov        [rsp+0x18], rbx
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48A5 48897 C2420        mov        [rsp+0x20], rdi
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48AA 4156              push       r14
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48AC 4883 EC20          sub        rsp, 0x20
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48B0 488 BDA            mov        rbx, rdx
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48B3 4 C8BF1            mov        r14, rcx
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48B6 4883 FA20          cmp        rdx, 0x20
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48BA 7307              jae        0x13f1c48c3
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48BC BB20000000        mov        ebx, 0x20
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48C1 EB13              jmp        0x13f1c48d6
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48C3 488 BCB            mov        rcx, rbx
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48C6 83 E107            and        ecx, 0x7
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48C9 740 B              jz         0x13f1c48d6
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48CB B808000000        mov        eax, 0x8
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48D0 482 BC1            sub        rax, rcx
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48D3 4803 D8            add        rbx, rax
2018.05.15 12:50:04.661 Pred_Find (GBPUSD,M1)                 000000013 F1C48D6 498 B4620          mov        rax, [r14+0x20]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48DA 33 FF              xor        edi, edi
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48DC 4885 C0            test       rax, rax
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48DF 0 F8485000000      jz         dword 0x13f1c496a
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48E5 483 B58F8          cmp        rbx, [rax-0x8]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48E9 7616              jbe        0x13f1c4901
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48EB 488 B5008          mov        rdx, [rax+0x8]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48EF 33 C0              xor        eax, eax
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48F1 0 FB6CA            movzx      ecx, dl
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48F4 4883 E2FC          and        rdx, 0xfc
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48F8 80 E102            and        cl, 0x2
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48FB 480 F44C2          cmovz      rax, rdx
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C48FF EB0E              jmp        0x13f1c490f
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4901 488 BF8            mov        rdi, rax
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4904 488 B00            mov        rax, [rax]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4907 A802              test       al, 0x2
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4909 7509              jnz        0x13f1c4914
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C490B 4883 E0FC          and        rax, 0xfc
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C490F 4885 C0            test       rax, rax
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4912 75 D1              jnz        0x13f1c48e5
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4914 4885 FF            test       rdi, rdi
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4917 7451              jz         0x13f1c496a
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4919 488 BD7            mov        rdx, rdi
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C491C 498 D4E18          lea        rcx, [r14+0x18]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4920 E89B0F0000        call       0x13f1c58c0  ; #5079 (terminal64.exe)
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4925 4 C8B47F8          mov        r8, [rdi-0x8]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4929 4 C2BC3            sub        r8, rbx
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C492C 4983 F820          cmp        r8, 0x20
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4930 7224              jb         0x13f1c4956
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4932 4983 C0F8          add        r8, 0xf8
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4936 488 D5308          lea        rdx, [rbx+0x8]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C493A 4803 D7            add        rdx, rdi
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C493D 498 D4E18          lea        rcx, [r14+0x18]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4941 4 C8942F8          mov        [rdx-0x8], r8
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)      crash -->  000000013 F1C4945 4 D894410F8        mov        [r8+rdx-0x8], r8
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C494A 48895 FF8          mov        [rdi-0x8], rbx
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C494E 4 D8B4618          mov        r8, [r14+0x18]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4952 41 FF5008          call       qword near [r8+0x8]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4956 488 BC7            mov        rax, rdi
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C4959 488 B5C2440        mov        rbx, [rsp+0x40]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)                 000000013 F1C495E 488 B7C2448        mov        rdi, [rsp+0x48]
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   00: 0x000000013F1C4945
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   01: 0x000000013F63EA90
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   02: 0x00000000FFFFFFFF
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   03: 0x000000005A3CD7A0
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   04: 0x000000013F6303ED
2018.05.15 12:50:04.662 Pred_Find (GBPUSD,M1)   
 
Konstantin:

\on the help - yes, it has been heavily rehashed, because when I was dealing (about two years ago) with postfix and prefix operations in mql, I obviously do not remember this material now

in general, the topic was closed, and we introduced this difference and did it well, but you have to warn them about the changes, don't you?

For the sake of interest I decided to check on the old 1159 build from June 2015. Its help has everything that Slava quoted. So maybe you got something mixed up.

 
Aleksey Vyazmikin:

What the hell is that thing?

It's a crash:) Go to servicedesk!

 
Alexey Kozitsyn:

It's a crash:) Go to servicedesk!

Got it - broke the bank :)

 
Aleksey Vyazmikin:

I see - broke the bank :)

It happens)

 
Alexey Kozitsyn:

It happens)

I don't know how to localise this error? I just don't want to give away the whole script, and I don't want to re-pack everything....

Reason: