Errors, bugs, questions - page 1354

 

Gentlemen, how would you like to significantly improve the usability of the language by addingproperty: https://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx

The constant dancing with setters, getters and brackets is very annoying.

 
Alexey Navoykov:

Gentlemen, how would you like to significantly improve the usability of the language by addingproperty: https://msdn.microsoft.com/en-us/library/x9fsa0sw.aspx

The constant dancing with setters, getters and brackets is very annoying.

Alexey, I'm all for it, but we should do a vote, not here. Here are some crutches, I haven't tried it in MQL http://rsdn.ru/article/vcpp/props.xml
Свойства в С++
  • rsdn.org
В этой статье автор рассматривает различные способы реализации свойств в стиле Visual Basic на C++. Некоторые способы специфичны для Visual C++, тогда как другие годятся для применения в любой программе, написанной на языке C++.
 
Alexey Volchanskiy:
Alexey, I'm all for it, but we should do a vote, not here. There are some crutches here, I haven't tried it in MQL http://rsdn.ru/article/vcpp/props.xml

There's something wrong with the encoding on your link. I'm getting a lot of red text. But I know what you mean, I've read about these crutches before. It's not possible to implement it in MQL at the moment, because ghost operator overloading is not supported.But this native feature in VS is very useful, especially when wrapped in a macro. And it doesn't consume any additional resources. So, it's high time we implement properties in MQL too, because everything looks clumsy without them.

 
Alexey Volchanskiy:

I figured it out, found a bug in MQL4 compiler. I was inattentive and it took me 2 days to find it. The essence of the problem is this: I will give you the simplest code. I don't get a compilation or warping error, I get a runtime error.

    double ptest = double(test); // тут должна быть ошибка компиляции!!! 

There is no need for any mistake here. There is a clear type conversion here. It would be like this in VS

  double ptest = (double)(int)(test);
What difference would it make?
 
A100:
There is no need for any mistake here. There is an explicit type conversion here.
You cannot cast a class to a meaningful type, even explicitly. There is definitely an error.
 
Please remind me how to sort the symbols in the market overview window (MT4, MT5). On one terminal they are nicely sorted, on the other one they are a mess. I sorted it a long time ago - I don't remember how I did it. There is nothing in documentation about it, except for dragging symbols one by one to a new place. But I have not done it exactly - it is possible to sort the whole list manually. :-/
 
Vasiliy Sokolov:
You cannot cast a class to a meaningful type, even explicitly. It is definitely an error.

It's not a class, it's a pointer, and a pointer is a number.

class A{};
void f()
{
        A *a;
        int i = int(a);
}

C++ compiles without errors

If you disallow a direct explicit conversion to double, the next time it will have int instead of double with the same result and the compiler will be guilty again. You have to distinguish your own errors from the compiler's errors.

 
A100:

It's not a class, it's a pointer, and a pointer is a number - learn the math.

C++ compiles without errors

If you disable direct explicit conversion to double, the next time it will have int instead of double with the same result and the compiler will be guilty again. You should distinguish your own errors from the compiler's errors.

There is no pointer there, because pointers do not exist in MQL4/5. There are handles.

----------------------

I've received an answer from Service Desk

Support Team 2015.08.24 09:44
Thanks for the post, will fix it.
Indeed, there must be a compilation error here.


Support Team 2015.08.24 14:39

Status: Open Closed
Thanks for the post, fixed. The compiler will now give a compilation error.
 
Alexey Volchanskiy:

There is no pointer there, because there are no pointers in MQL4/5. There are descriptors.

A descriptor is still a specific number. The fact that this number does not point to a specific memory location does not deprive it of the properties of a number.
 
A100:
A descriptor is still a specific number
Of course, in terms of "how it's stored in memory", you're right.
But it makes no sense to convert a descriptor to a number or vice versa, and it's most likely a bug in the code.
In the near future, if an appropriate conversion statement is overloaded in the class, it will be called.
Reason: