Errors, bugs, questions - page 2839

 

On charts (particularly EURUSD) with monthly and weekly timeframes, the crosshair moves very slowly following the cursor - just move the cursor smoothly diagonally to play. It is OK in other timeframes. There was no such delay before


 
A100:
Execution error:

Result: 1-2-2-0-0-0

Expected result: 1-2-0-0

as in C++. Also, the syntax was expected to be consistent: a cast is a cast, not a constructor call

Everything seems to be correct. It's just that the move constructor is probably called there, which in MQL is replaced by copy.
And the conversion is like (A)a1.
 
Alexey Navoykov:
Everything seems to be correct, I think. The move constructor is probably called there, which in MQL is replaced by copy.
A conversion is like (A)a1

(A)a1 or A(a1) is not a cast, it is a declaration of a type like in the docs. Although now there is something wrong with brackets. A single format is needed for the language.

 
Valeriy Yastremskiy:

(A)a1 or A(a1)type conversion A a1 is not a conversion, but a type declaration like in the docs. Although now there is something wrong with brackets. A common format is needed for the language.

The difference is that (A)a1 in pluses means the object copy conversion. And in MQL it is the reference conversion. Because of this, one can get a compatibility problem.
Long ago I asked them to make a conversion like in pluses: (A&)a1, but now they probably won't change anything.
 
Alexey Navoykov:
The difference here is that in pluses (A)a1 means bringing in a copy of an object. And in MQL it is the reference conversion. Because of this, one can encounter compatibility issues.
I've long asked them to make a sonic conversion like in the pros: (A&)a1, but they're probably unlikely to change anything now.

Not si not python) something in between. Oops, didn't know, figured the object type conversion. Economy).

 
Alexey Navoykov:
Everything seems to be correct. It's just that the move constructor is probably called there, which in MQL is replaced by copying.
And the ghost is like (A)a1

I doubt it's right, because let's say:

class A {
public:
        virtual void f() { Print( 1 ); }
};
class B : public A {
public:
        virtual void g() { ((A)this).f(); }
};
class C : public B {
public:
        virtual void f() { Print( 3 ); }
};
void OnStart()
{
        B *b = new C;
        b.g();
}

The result in MQL: 3

and in C++: 1.

In any case, have them check

 
A100:

I doubt that this is correct, because let's say:

The result in MQL: 3

and in C++: 1.

In any case, have them check

So this is exactly the situation I described above.
 
A100:

I doubt that this is correct, because let's say:

The result in MQL: 3

and in C++: 1.

In any case, let them check it.

I wouldn't be so definite when interpreting MQL code in C++.
Code for C++ (online: https://onlinegdb.com/Hy1FIj9Qv):

class A {
public:
        virtual void f() { printf( "1" ); }
};
class B : public A {
public:
        virtual void g_ptr() { ((A*)(this))->f(); }   //3
        virtual void g_ref() { ((A&)(*this)).f(); }   //3
        virtual void g_cast() { ((A)(*this)).f(); }   //1
};
class C : public B {
public:
        virtual void f() { printf( "3" ); }
};
void OnStart()
{
        B *b = new C;
        b->g_ptr();
        b->g_ref();
        b->g_cast();
}

int main()
{
    OnStart();
    return 0;
}
 
Sergey Dzyublik:

I wouldn't be so unambiguous when interpreting MQL code in C++.
The code is for C++ (online: https://onlinegdb.com/Hy1FIj9Qv):

And how do you propose to write the 3rd version of g_cast in MQL ?

 
A100:

And how do you propose to write the 3rd version of g_cast in MQL?

You can explicitly call the function from the base class:

class A {
public:
        virtual void f() { Print( 1 ); }
};
class B : public A {
public:
        virtual void g() { this.A::f(); }   //1
};
class C : public B {
public:
        virtual void f() { Print( 3 ); }
};
void OnStart()
{
        B *b = new C;
        b.g();
}