and yet my code compiles. Why?
Your code will compile, but it will not execute.
Interesting - but why would it let me compile if this is a show-stopping bug?
Ah, I understand now. Thank you. Although it seems odd that such errors can't be caught by the compiler. It seems like it would be trivial?
clemmo: Ah, I understand now. Thank you. Although it seems odd that such errors can't be caught by the compiler. It seems like it would be trivial?
Because in MQL, arrays can be resized at runtime, so there can be code being executed in another region that would then make that line valid at runtime.
clemmo: Ah, so if the array was properly resized in a later step, this code might execute correctly after all?
Since the compiler does not have the higher inelegance to analyse and understand every logical path your code might take, it does not check for "array out of range" scenarios during compilation and only during runtime.
Very helpful, thank you.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It would seem to me that attempting to access the fourth element in an array of size 3 should generate an array out of range error, and yet my code compiles. Why?