Errors, bugs, questions - page 2753
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
In C# the const specifier is used only for constant expressions calculated at the compilation stage, while C++ has an analog for it: constexpr,and MQL doesn't have it.
yes
it's generally a question of syntactic constructions of languages
in a natural language (in mathematics) a constant is... well it's kind of a constant! ))
In C++ a constant is a machine checking by the compiler for a constant in the scope (or lifetime) of a variable
In C# a constant has a syntactic meaning which is closer to the rules of a natural language
And that's what this discussion is about:
Imho, this construct fully complies with C++ syntax, or at least MQL4 had Bid and Ask and nobody doubted whether it was justified
Without demagogy we need the possibility to access current prices as quickly as possible. The profiler shows that permanent access to SymbolInfoDouble() and SymbolInfoTick() decreases the optimization speed
How can I change the compiler?
I found out that the compiler is built into MetaEditor from the 900 build:https://www.mql5.com/ru/forum/21374
Then why is there a window with a line leading to the directory where VS is installed?
Without demagogy, we need to be able to access current prices as quickly as possible. The profiler shows that constant calls to SymbolInfoDouble() and SymbolInfoTick() reduce optimization speed
Well, here's where it was suggested earlier to add the ability to pass NULL instead of the current symbol name. This could speed up work in special cases. In general, we need access through handles, not text values of symbols. But I think the developers are unlikely to go for such complication. The problem seems to be farfetched.
In the above mentioned measurements the cost was only 6% of the tester's idle run (without load). And in working code it will be an order of magnitude less. It's not worth paying attention to such trifles, and calling these functions more than once in a handler is an incorrect decision in itself.
Well here earlier it was suggested to add possibility to pass NULL instead of current symbol name. This could speed up work in special cases. But in general we need access via handles, not text values of characters. But I think developers are unlikely to go for such complication. And it is not worth it, it seems to me. The problem is rather farfetched.
It already works, but there is no acceleration (I checked) - apparently everything is already maximally accelerated or vice versa - for acceleration is still a long way off (please ask the developers to underline)
Therefore, for the sake of strictness, we should use Digits() instead of _Digits. Then formally and no logical contradiction occurs - Digits() is not bound by const modifier.
As far as I understood _Digits was needed for compatibility with MT4 - nothing more.
Forum on trading, automated trading systems and strategy testing
Bugs, bugs, questions
Ilyas, 2020.05.20 15:39
calling of Symbol() ALWAYS accesses to global variable _Symbol, as well as Digits(), Point(), Period(), GetLastError(), IsStopped(), UninitializeReason()
During debugging and when the indicator is working itself, in the log, it suddenly writes Stack overflow. When debugging itself, the message "Critical error occurred, debugging stopped" pops up. Here is my similar thread:https://www.mql5.com/ru/forum/338301. But during compilation the compiler doesn't scold and everything goes fine. When debugging, it's impossible to determine at what point the program crashes.
Maybe it's the compiler? I'm not really interested in the compiler I'm using, but in my settings it looks like this:
I have VS installed, so I have this link in the settings. So the compiler is appropriate too...? But what compiler was there when I didn't have VS, I honestly didn't get into it. Maybe I should try to go back to that compiler and try to compile the project with it?
While I was looking for ways to solve the problem, with the arrival of another terminal update debugging worked properly. I managed to find errors. Some methods were looping and calling themselves. That's why the program crashed with the message "Stack overflow". But with the help of a working debugger I have managed to find all the problematic lines and fix them. I express my gratitude to the Developers for quick fixing of the bug with debugging!
в естественном языке (в математике) константа это... ну как бы константа! ))
In C++, a constant is a machine check by the compiler on the constancy in the scope (or lifetime) of a variable.
In C++ as well as in MQL, a constant can be defined once at creation and never be changed again. Scopes have nothing to do with it.
It's not much different than in mathematics.
I found out that the compiler is built into MetaEditor from the 900 build:https://www.mql5.com/ru/forum/21374
Then why this window with a line leading to the directory where VS is installed?
The VS compiler is used if you write a DLL.
Which once again confirms that there is no sense inusing _Digits,_Point , _Period, _LastError, etc.directly(and even _Symbol can be replaced by NULL). In fact, they must be declared as const volatile
And you, on the contrary, are suggesting to add
Which once again confirms that there is no point inusing _Digits,_Point , _Period, _LastError, etc.directly. And even _Symbol may be replaced with NULL.
And you, on the contrary, are offering to supplement this series.
The point is in the possibility to pass by reference.