Errors, bugs, questions - page 1355

 
Ilyas:

In the near future, if an appropriate conversion statement is overloaded in a class, it will be called.

Mmmm, yummy ) very good news
 
I honestly didn't see anything wrong with this conversion, given that it's explicit. Why would there be a mistake here? If someone wants a numerical value for a descriptor, there's no mistake about it.
 
Ilyas:
But it makes no sense to convert a descriptor to a number or vice versa, and this is most likely a bug in the code.
I have code fragments where pointers are explicitly converted to numbers (for interfacing with external write/read systems, as well as for error analysis and debugging), if this is forbidden then flexibility will be reduced and we will have to redo.
 
Ilyas:
Of course, in terms of "how it is stored in memory", you are right.
But it doesn't make sense to convert the 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 operator is overloaded in a class, it will be called.
There might be a warning here but not an error.
 
Ilyas:
Of course, in terms of "how it's stored in memory", you're right.
But it doesn't make sense to reduce the 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 operator is overloaded in the class, it will be called.

Of course, it was my inattention error, I've already written about it. I have 95% of errors at all, not system errors, but due to inattention )) By the way, I don't see the point in casting a descriptor to a number, either. It's more interesting with pointers where there's pointer arithmetic, for example, you may decompose double into bytes or do something non-trivial. And a descriptor is just an internal identifier, given by MT4 runtime system, you can't do anything with it.

That's how this error occurred, no need to write code at night ))

// order - это дескриптор экземпляра класса, создается вот так после открытия ордера, потом заносится в CList открытых ордеров.
// COrder* order = new COrder(ticket, symbol, cmd, volume, price, timeOpen, magic, stoploss, takeprofit, comment, expiration);

// так было неправильно, просто я перепутал order с тикетом, забыл, что это же экземпляр класса, уставший был ))
logBuf[logBufCount++] = double(order);

// так правильно
logBuf[logBufCount++] = (double)order.Ticket
 
A100:
A descriptor is still a concrete number. Just because it doesn't point to a particular memory section doesn't deprive it of number properties.

Then string is also a set of specific numbers. And a picture is also a number and an electrical pulse on a chip...

In general, study electrical engineering, colleague.

 
Alexey Navoykov:
To be honest, I didn't see anything wrong with this citation, considering that it's explicit. Why should there be an error here? ...

Because type control is violated, and the managed environment, which is the MQL virtual machine, should prevent such things:

MQL != C++

 
Ilyas:
Of course, in terms of "how it is stored in memory", you are right.
But it doesn't make sense to convert the descriptor to a number or vice versa, and it's most likely a bug in the code.
In the near future, if the appropriate conversion operator is overloaded in a class, it will be called.
Very cool and most importantly ideologically correct. Two hands in favour!
 
Alexey Volchanskiy:

By the way, I don't see the point of reducing the descriptor to any number either...

There is such a point. This is a very useful property for specific data containers, such as dictionaries, where the descriptor, by definition unique, can be the key to a class. In this case there will be no need to calculate its hash and, most importantly, you can distinguish the uniqueness of objects by reference and by value (which is actually different concepts). In addition, classes that are not related to each other by inheritance can be placed in the collection.
 
Alexey Volchanskiy:

And the descriptor is just some internal identifier given by the MT4 runtime system, you can't do anything with it.

Others do. Open up new horizons.