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
I removed some of my post as I confused with another thread.
It works as it is. You can't expect the language to work as you wish, YOU have to follow the language rules.
From documentation :
I've understood the situation since Marco gave the passage in docs about static arrays.
MT5 wants to make the array static when initialized like that, ok, their choice.
But I don't like 100% followers, sorry. Like "shut up and do".
This is a forum, for talking, input, feedback, (and ideally voting)
I just put out my opinion, against MT5 devs's choice, which I find it not intuitive.
No in the first example it should be static because you specify it will only be dynamic if it can not determine type and fill in or calculate elements.
Once you specify:
It makes all the difference.
If you want dynamic first declare open or endless situation:
then it can not know or calculate type and size so it HAS to assume dynamic.
then specify:
Resize, and then fill.
It's logical operations not intuitive.
for me it is only logically, once you specify:
it's way of managing resources here.
if this wasn't so, how would it have to calculate resources? it would not have a clue and go funky.
Marco,
I understand that you accepted their logic, as yours.
And that you don't like (my) intuition, ok.
What I'm saying, is the compiler should let the array dynamic. It should not make the array static.
Allocate, manage, whatever, but in the end, let the array dynamic.
That's my point.
And if you want to blame someone, blame Bjarne Stroustrup.
Have you read his books?
Once it sees your initializer list, it will calculate size and that's the way it is / was designed.
there is more about this and why it's like that in his books i can recommend them it has to do with several things actually.
It's only logical, and this is actually working in our favor.
And if you want to blame someone, blame Bjarne Stroustrup.
Have you read his books?
I appreciate your insistence.
I don't want to blame anyone, just want to express my opinion that's all.
I didn't read his books.
I'm curious if, in c++, after writing your example above, the programmer would be able to resize the array.
But that's c++ anyway, not mql5.
I found this link
So in c++ there are only static arrays (although a guy says you can use malloc and realloc afterwards, which means you can resize the array afterwards)
For dynamic arrays, std:vector.
=> there's no blame for Bjarne Stroustrup anyway.
So it's all about MQL5, and the decision to make the array static when initialized, which I don't agree, my opinion.
But maybe it's a bug, not even a conscious decision of mql5 devs.
yes well it has got to do with:
‘‘ability to grow’’ vs. ‘‘guaranteed to be allocated in a fixed location’’
And:
‘‘elements do not move when elements are added’’ vs. ‘‘contiguously allocated.’’
If you do not understand this, i rest my case.
I appreciate your insistence.
I don't want to blame anyone, just want to express my opinion that's all.
But maybe it's a bug, not even a conscious decision of mql5 devs.