Generic Class Library - bugs, description, questions, usage and suggestions - page 21

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
We just need to overload GetHashCode for required type instead of starting IEqualityComparable.
In this case the ends go very far, and possible error will appear somewhere in the depths of the library. And then guess why some function is not found and whose fault it is. And interfaces guarantee in advance that all necessary functions are already defined in the object.
In this case, the ends go very far, and the possible error occurs somewhere in the depths of the library. And then guess why some function is not found and whose fault it is. And interfaces guarantee in advance that all the necessary functions are already defined in the object.
Can you show an example for MqlTick?
And interfaces guarantee in advance that all necessary functions are already defined in the object.
Yeah, except that these classes claim to be universal and should work for all types out of the box.
Can you show me an example for MqlTick?
There are costs here, of course, that we'll have to put in a class, plus pointer check.
Thank you, but I can not understand what is the advantage of this approach in practice?
In SB, the code is as follows
It turns out that the proposed dances only in order not to overload this GetHashCode. But is it worth the trouble in this case?
Thank you, but I can not understand what is the advantage of this approach in practice?
In SB, the code is as follows
It turns out that the proposed dances only in order not to overload this GetHashCode. But is it worth the trouble in this case?
If speed is critical, then probably it's better to overload.
The point is that in .NET, where this library was ported from, all built-in types already have interfaces from the beginning. This is how int, aka Int32, is defined:
That's why there's no overloading there.
And the CKeyValuePair class itself would be declared a little differently.
Although it would be better to spend this time on improving the functionality of the language. Then it would be enough to copy the entire .Net library and everything would work.
There are costs here, of course, that you'll have to put in a class, plus pointer check.
What's the problem with shoving this code into the GetHashCode overload? then you don't need to inherit from the interface
It is possible, of course. But it complicates control over the process. Suppose you have a bunch of different GetHashCodes, scattered throughout the code, and which of them are called here (and where they are located), it can be difficult to understand. For example when calling a function, the argument casts to some other type. In C# this is probably why the template possibilities are very limited comparing to C++
It is possible, of course. But it complicates the control of the process.
In C++ this interface is unnecessary, normal interaction is achieved by simple overloading of operator <, and this operator can be defined outside the CLASS.
I think it's much easier and laconic than to turn such constructions. but you need native support of overloading operator < outside the class.
And for built-in structures there is nothing but overloading GetHashCode, because the stub is horrible and inheritance is impossible. Inheritance from structure is a crutch solution, because when using standard functions you have to manually cast structure to user inheritor to make everything work as intended.Inheritance from a structure is a crutch solution, because it forces you to manually cast the structure to a custom inheritor when using standard functions to make everything work as intended.
Apparently you don't mean inheritance, but wrapping from a class over a structure?
Actually, such "forcing" is also a disadvantage of MQL functionality, since there is no way to overload the cast operator, otherwise the class would easily be cast to the structure implicitly.
But nobody bothered... The development has been stagnant for 2 years, no improvements and innovations.
While developers themselves here complain about the lack of multiple interfaces and other features, but continue to eat a cactus.)