SDC:
OLD MQL4 | NEW MQL4 WITH STRICT |
---|---|
Variable scope is from declaration (even in the nested block) to the function end | Variable scope is from declaration to the end of the block, in which the variable is declared |
Does that mean in strict mode a local variables scope is defined by { } ?
Yes, here's script example :
void OnStart() { int lol = 4; //--- for (int pos = 0; pos < lol; pos ++) { } for (pos = 0; pos < lol; pos ++) { } }
when compiled, local variable pos (in red on example above) is an undeclared variable, while variable 'lol' is fine.
Variable 'lol' is in OnStart scope, and the first variable 'pos' is within the scope of first 'for' loop. However the second variable 'pos' is in the scope of second 'for' loop and not declared yet.
hmmmm ok thanks OWZ I must have completely missed that in the earlier beta release notes.

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
Does that mean in strict mode a local variables scope is defined by { } ?