Features of the mql5 language, subtleties and tricks - page 161
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
2020.01.27 01:15:57.859 tst (EURUSD,H1) (null) , 0.000000 , 0
if I remove type conversion, the 'NULL' - expression of 'void' type is illegal
interesting, it turns out that nput string can be initialized void
NULL is initialisation. The example purposely shows a non input string.
NULL / NIL (in other terms) cannot be an initialization of a constant string entity.
At least because the mql string is not a "pointer" like in C. It has no special state "nothing at all".
PS (oh, I did not expect that from myself)
She has no special state of "nothing at all"
Forum on trading, automated trading systems and trading strategies testing
Peculiarities of mql5, tips and tricks
fxsaber, 2020.01.26 15:54
I use this condition every day.
at least because an mql string is not a "pointer" like in C. It has no special state "nothing at all".
PS (oh, I didn't expect that from myself).
alas no, a string in MQL is an entity with allocated memory.@Ilyas explained why StringBufferLen() may not show the string length, but shows the memory used to store the string.
I use this condition every day.
It's no indicator at all, in MQL4 I unset pointers to any object using StringConcatenate(), i.e. the built-in functions work is not implemented by MQL rules )))
It's no indicator at all, I unset pointers to any object in MQL4 using StringConcatenate(), i.e. the built-in functions are not implemented by MQL rules )))
Doesn't make any difference what's inside.
Forum on trading, automated trading systems and strategy testing
Peculiarities of mql5, tips and tricks
Igor Makanu, 2020.01.26 22:27
It makes no difference how it is inside.
supplemented my post with your example
I also did a couple more experiments with input string s = NULL;
as far as I understood, while we're not trying to use input variable's value - it will be NULL, but the moment we try to assign value to another variable or simply unset it, NULL will disappear, i.e. memory will be allocated to this input variable
as far as I understand, while we're not trying to use the value of an input variable - this value is NULL, but at that moment, if we try to assign the value of this input variable to another variable or simply unset this input variable, then this NULL will disappear, i.e. memory will be allocated to this input variable
The mechanism of input variable operation has been described in detail above.
It doesn't make any difference what's inside.
there is (still) specificity of entity dereferencing (there are no pointers in mql, it's not C, let there be entities)
input is a const declared at startup. you cannot physically give it the value "NULL".
const string nothing=NULL; /// <--- ЭТО ЧТО ?
Yes, this behaviour is probably just "foolproof".
Apparently, because input variable must be initialized, the= NULL is artificially equated to ="", when the variable already occupies at least one byte in memory.
In MQL5 the entries:
Are absolutely identical. No memory is allocated for the variable. Anyway, I haven't found any differences.
In java, for instance, such records are slightly different, despite the fact that no memory is allocated for the variable in both cases, too. The first variant (String str = null;) will be considered initialized, although no memory is allocated for the variable and the variable can be printed as empty. In the second case (String str;) when you try to print the variable, an error of uninitialized variable will be generated.
I.e. MQL5 is more tolerant in this regard.
Which is better, I don't even know.
How is memory not allocated to a variable?
The memory is allocated and the variable contains arbitrary rubbish.
And the fact that string does not output any values, it is logical that the buffer is empty.
How is memory not allocated to a variable?
The memory is allocated, but the variable does not contain arbitrary rubbish.
And the fact that string does not output any values, it is logical that the buffer is empty.