Errors, bugs, questions - page 2565

 
Igor Makanu:

I'm not going to argue

I decided to describe the problem that we're discussing. By the way, MQL's behavior has become more and more similar to that of C#, the code does not compile

//+------------------------------------------------------------------+
class A
{
private:
   int               count;
public:
                     A():count(0) {}
   static void       inc()        { count++; }

};

A a;
//+------------------------------------------------------------------+
void OnStart()
{
   a.inc(); //code generation error 
   A::inc();
   
}
//_______________________________________________________________________

I've implemented Inc() method - it works with protected fields

if i added a static modifier - where should the compiler stop checking? - i've decided i need an entry point to an object out of scope?

 
Igor Makanu:

If you have written a static method/field or applied a ::: - do not rely on the compiler

Bugs happen. I write code as before: this, ::, const, static, private, public, protected are put wherever it is possible.

I need it first of all for a quick understanding of my code. Secondly, I want the compiler to help me while writing my code. It helps me a lot.


Yesterday I faced such a situation for the first time. I wrote a 5Kb code some part of which was copied and pasted from various fragments. And when compiling it for the first time there appeared not a single error or warning. I was surprised.

 
Igor Makanu:

I have decided to describe the problem we are discussing

//+------------------------------------------------------------------+
class A
{
private:
   int               count;
public:
                     A():count(0) {}
   static void       inc()        { count++; } // Здесь ошибка, о которой компилятор сейчас не сообщает.

};
 
Igor Makanu:

I decided to describe the problem that we're discussing. By the way, MQL's behavior looks more and more like C#, the code doesn't compile

the inc() method - it works with protected fields

if i added a static modifier - where should the compiler stop checking? - i made a decision that i need an entry point to an object out of scope, right?

Your count variable is not static.

How does a static function know which object this variable belongs to?

 
Koldun Zloy:

Your variable count is not static.

How will a static function know which object this variable belongs to?

not a principle, I mean that any implementation of working with static methods will not have a complete check by the compiler, and the entire responsibility for control falls on the programmer

ok, never mind, because it doesn't matter - I wrote the same thing twice in one dayhttps://www.mql5.com/ru/forum/1111/page2564#comment_13249284

 
Igor Makanu:

I mean that any implementation of static methods will not be fully validated by the compiler, and all the responsibility for control falls on the programmer

Where did you read this?

Did you invent it yourself and repeat it without stopping?

 
Andrey Barinov:

Where did you read that?

Did you make it up yourself and keep repeating it?

I didn't come up with it, it's my opinion... like, in principle, to close all work with statics only within statics as in C# - then there will be no questions or errors ;)

 
Slava:

A few questions on the platform:

1. will a permissible trading range be added for VPs via MOEX (e.g. EURRUB_TOM)? Right now it is impossible to know for sure if a limit will be set, as there is no access to the range (max and min possible prices). Please add.

2. Is it possible to add to the terminal and meta-editor an auto-save status every N minutes? Very lacking, as with a sudden disconnection you go back to the state at the start of the program with loss of all changes! Very stressful!

 

MQ, are you guys OK with the storage? It takes 10-20 seconds to commit a file. It used to be instantaneous...

Added: sometimes the commit just hangs...

 
In the indicator on the chart with the custom tool, calling the CopyBuffer function(with the handle of the usual mask for real symbols, e.g. for EURUSD) returns error 4806. The custom symbol is based on the formula XAUUSD/31.1035*USDRUB. The same custom indicator with the same settings works fine on a real chart (like XAUUSD, GBPUSD etc). What could be the problem?