Errors, bugs, questions - page 2045
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
But I set the wrong array dimension there, maybe it affected it somehow (although it shouldn't affect it at all).
Try this with dimension = 3
Discovered the cause of the discrepancy. With OPTIMIZE=0 there is an error, but not with OPTIMIZE=1. I usually only use OPTIMIZE=0
If I find a logical (non-contradictory) explanation for the result, I don't see the bug. I don't think it's acceptable to prove a bug if the result doesn't match C++. It's in C++ that someone thought that way and did it. But they might not have thought so and therefore didn't do it. That's why it's better not to refer to something out there, but rely on your own inner concept of what must be. And it is desirable that this "own" should really be one's own. Not the result of imperceptible imposition of stereotypes "the way it should be" as you gain programming experience.
If you do not have your own explanation, it means that there is no error. And if this explanation appears a year later and is rather convincing, will everybody have to redo everything? In C++ they have already thought a hundred times why it's done this way and not that way. And the explanation is needed if something is set up differently in MQL than in C++ and not vice versa.
But not a function.
Then static class instances should be banned - because they are initialized by a constructor function
And here's more on the topic of variable initialisation. If you follow what was stated in the documentation, then you can't reference other global/static variables either. As it is not a constant expression:
However, for now it works. And I suppose many people have always used such constructs without realizing it. But it turns out that the developers may disable it at any moment. And, as in the case with function initialization, these codes will still compile successfully, but they won't work correctly. All in all, the whole MQL is a time bomb.
And here is another thing concerning variable initialization. If you follow what was stated in the documentation, then you can't reference other global/static variables either. Because it is not a constant expression:
is initialised by a constructor function - prohibit!
This is if you logically summarise the last posts
Found out the reason for the discrepancy. With OPTIMIZE=0 there is an error, but not with OPTIMIZE=1. I always use only OPTIMIZE=0.
In the 32-bit terminal an error occurs at any OPTIMIZE
is initialised by a constructor function - prohibit!
This is if you logically summarise the last posts
Well, the person just expressed it incorrectly there. Of course, we are talking about an initializing value, not an initializing function.
And what the hell with them - bans. They do not cause troubles by themselves. But when this prohibition is not controlled by the compiler in any way but generates an algorithm that bypasses language rules, it does not fit at all. Now you'll have to dig through all the code looking for such things and be constantly on guard. Well, fuck that kind of programming, I'd rather stay on the old build.
I see, I apologise then, I didn't notice straight away. I'm surprised, of course, how they managed to change it quietly and didn't tell anyone. What I don't understand is why the compiler doesn't react to an invalid operation being executed. That is, the bug is present in any case.
And here's more on the topic of variable initialisation. If you follow what was stated in the documentation, then you can't reference other global/static variables either. As it is not a constant expression:
However, for now it works. And I suppose many people have always used such constructs without realizing it. But it turns out that the developers may disable it at any moment. And, as in the case with function initialization, these codes will still compile successfully, but they won't work correctly. All in all, the whole MQL code is a mine mine working in slow motion.
Well... there is no discrepancy with the description in the documentation in this example... Take a good look at the quote from the documentation
or by a constant expression
This initialization is possible. Because the 'a' variable is initialized by a constant and the 'b' variable is initialized by a constant expression.
Then you need to prohibit static instances of classes - because they are initialized by constructor function
Pay attention to
Forum on trading, automated trading systems and trading strategies testing
Bugs, bugs, questions
Alexey Viktorov, 2017.10.18 09:19
Why do you think you have changed, why is it unacceptable? Please use at your own discretion. The whole problem is that when a static variable is initialized by a function, the initialization is "paused" and that function is executed. And in the above example, there is still a static variable in that function that hasn't been initialized yet. Hence, a variable initialized by a function takes a different value.