Hi, I can't find any statement about this in the documentation.
The question:
Are static+dynamic arrays of structs like MqlTick and MqlRates in mql5 in memory always complete in one piece (like C++ std::vector)?
So that elements/arrays can be accessed e.g. from dll using a pointer?
Or is it possible that the arrays of MqlTick+MqlRates are NOT stored contiguously in RAM (like C++ std::deque) and thus the access by pointer can be dangerous?
Arrays are always contiguous, the only thing to be aware is when you resize them, the starting address might change.
Since MqlTick and MqlRates are considered simple structures their bytes can even be copied directly to another structure
and the compiler does that when you assign them.
- www.mql5.com
Arrays are always contiguous, the only thing to be aware is when you resize them, the starting address might change.
Since MqlTick and MqlRates are considered simple structures their bytes can even be copied directly to another structure
and the compiler does that when you assign them.
Ok thanks that sounds good but how do you know for sure that it's really always in the ram in one piece? have you tried it statistically repeated (100%) or is there a metaquotes statement?
Because the statement "Arrays are always contiguous" related to RAM is not true in every programming language (best example c++ std::deque).
MQL5 is not C++, MQL5 is an own scripting language. How do you know it for sure that the sequential container in MQL5 like arrays of structs(MqlTick/MqlRates) is in one piece in the ram?
Forum on trading, automated trading systems and testing trading strategies
Are arrays of mql5 structs stored reliable complete in one piece in memory?
4lpha, 2022.01.06 16:42
Ok thanks that sounds good but how do you know for sure that it's really always in the ram in one piece? have you tried it statistically repeated (100%) or is there a metaquotes statement?
Because the statement "Arrays are always contiguous" related to RAM is not true in every programming language (best example c++ std::deque).
I am not even considering the performance implications.
I also implemented C++'s containers/iterators in MQL for my libraries and arrays are working just like the C++ ones.
Forum on trading, automated trading systems and testing trading strategies
Are arrays of mql5 structs stored reliable complete in one piece in memory?
4lpha, 2022.01.06 17:32
Yes in all C++ references this is all clearly described but not in MQL5 reference.MQL5 is not C++, MQL5 is an own scripting language. How do you know it for sure that the sequential container in MQL5 like arrays of structs(MqlTick/MqlRates) is in one piece in the ram?
Jes sure, the Array in MQL5 you can resize (https://www.mql5.com/de/docs/array/arrayresize). Resize is not possible with the real array in c++ (https://en.cppreference.com/w/cpp/container/array).
So the MQL5 array is not similar to the std::array but because the resize maybe to the std::vector or std::deque...
We do not know what exactly is behind the MQL5 array. Therefore the question.
I think you can't compare C++(low-level) and MQL5(interpreted high-level). There is only syntactic similarity nothing more.
- www.mql5.com
Jes sure, the Array in MQL5 you can resize (https://www.mql5.com/de/docs/array/arrayresize). Resize is not possible with the real array in c++ (https://en.cppreference.com/w/cpp/container/array).
So the MQL5 array is not similar to the std::array but because the resize maybe to the std::vector or std::deque...
We do not know what exactly is behind the MQL5 array. Therefore the question.
I think you can't compare C++(low-level) and MQL5(interpreted high-level). There is only syntactic similarity nothing more.
mql5 is not an interpreted language. It's compiled and managed language.
Of course mql arrays are contiguous in memory. It's implicit from the documentation and experience. If you want to prove it otherwise please do it and show us.
This is a good indication that it is similar to std::vector (contiguously in RAM). But we don't have a real proof, do we?
which uses arrays as its storage medium, and, the arrays are behaving as expected.
You still didn't answer my question, have you implemented something where the arrays are not behaving as expected?
Jes sure, the Array in MQL5 you can resize (https://www.mql5.com/de/docs/array/arrayresize). Resize is not possible with the real array in c++ (https://en.cppreference.com/w/cpp/container/array).
So the MQL5 array is not similar to the std::array but because the resize maybe to the std::vector or std::deque...
We do not know what exactly is behind the MQL5 array. Therefore the question.
I think you can't compare C++(low-level) and MQL5(interpreted high-level). There is only syntactic similarity nothing more.
Sure you can in C++, resizing an array is just a matter of allocating the new memory, copy the contents to the new array,
deallocate the old array and return the address of the new array.
Again, don't confuse std::array(which is a container) with array, they are not the same thing in C++.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I can't find any statement about this in the documentation.
The question:
Are static+dynamic arrays of structs like MqlTick and MqlRates in mql5 in memory always complete in one piece (like C++ std::vector)?
So that elements/arrays can be accessed e.g. from dll using a pointer?
Or is it possible that the arrays of MqlTick+MqlRates are NOT stored contiguously in RAM (like C++ std::deque) and thus the access by pointer can be dangerous?