Added StringLen to the test, and initialized the string differently. The documentation says one thing, the actual behavior is different. And buffer in this case shows 0 instead of 260.
The documentation specifies when 0 is returned and it is appropriate for the specified case
The documentation does not match the current behaviour at all!
Documentation: A value of 0 means that the string is a constant and the contents of the buffer cannot be changed.
The string is initialized with constant "_" and the compiler considers the string conditionally (for efficiency purposes) a constant - why not? Why is there a contradiction? All the more so because no further operations are performed with it.
I think I got it with number 260, the compiler itself allocates the initial size of theStringBufferLen buffer to 260. If the string length is less than 260, the StringBufferLen will print 260, not the actual string length! And if the string length is greater than 260, then the actual string value is printed.
So, using the StringBufferLen function, with a string length of less than 260 characters, we won't get the actual string length, and will always get 260. This must be an error. As soon as the length exceeds 260 characters, we will get the real string length.
p.s. as the documentation is out of date it is very misleading.
That is, using the StringBufferLen function, with a string length of less than 260 characters, we will not get the actual string length, and will always get 260. This must be an error. As soon as the length exceeds 260 characters, we will get the real length.
Strictly speaking string length: StringLen and buffer length: StringBufferLen are rather rare functions. And in general they may not coincide.
That makes two at least questionable cases:
voidOnStart()
{
string s1 = "_";
Print(StringBufferLen(s1)); //(1)//Ожидалось 260 вместо 0 - строка s1 далее может быть увеличенаStringInit(s1,1,'_');
conststring s2 = s1;
Print(StringBufferLen(s2)); //(2)//Ожидалось 0\1 вместо 260 - строка s2 константная и не может быть далее увеличена
}
The strategy tester optimization bug has not been fixed yet.
Please correct.
The optimization setting I use is balance + sharp ratio, but an abnormal optimization value is displayed as in the screenshot, and normal optimization due to this abnormal value is generated in the subsequent optimization generation. It is impossible.
The optimization I'm using is balance + sharp, but the abnormal optimization value is shown as in the screenshot and normal optimization due to this abnormal value is generated in subsequent optimization generation. This is not possible
The preallocated string memory size is an internal matter of the compiler and you cannot rely on it.
The executionresults show that the compiler acts contrary to logic:
For a constant string more memory is allocated than necessary (its length cannot be increased in principle)
For a non-constant string, no additional memory is allocated (if its length is increased, a new memory allocation will be required)
If a user initializes a string with StringInitInit, more memory is allocated than needed, because the buffer size is explicitly set by the user and in most cases it won't be increased (the user has already thought about what final buffer he needs and set its size explicitly)
The executionresults show that the compiler acts contrary to logic:
For a constant string more memory is allocated than necessary (its length cannot be increased in principle)
For a non-constant string, no additional memory is allocated (if its length is increased, a new memory allocation will be required).
If a user initializes a string with StringInitInit, more memory is allocated than necessary, because the buffer size is defined explicitly by the user, and in most cases, it will not be increased (the user has already thought about what final buffer he needs and defined its size explicitly)
Preallocation size of buffers for strings is an internal matter of the compiler.
We will change the handling of strings many more times.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Added StringLen to the test, and initialized the string differently. The documentation says one thing, the actual behavior is different.
And buffer in this case shows 0 instead of 260.
The documentation specifies when 0 is returned and it is appropriate for the specified case
The documentation indicates when 0 is returned and is appropriate for the case indicated
The documentation does not match the current behaviour at all!
And the results are different ))What is the difference between the two types of initialisation?
And it's not clear where the left number 260 is coming from.
The documentation does not match the current behaviour at all!
Documentation: A value of 0 means that the string is a constant and the contents of the buffer cannot be changed.
The string is initialized with constant "_" and the compiler considers the string conditionally (for efficiency purposes) a constant - why not? Why is there a contradiction? All the more so because no further operations are performed with it.
And in general it is not clear where the left number 260 is coming from.
The moderator explained where it came from, and why it in the case of
does not appear - reason to check
The moderator clarified where from
I think I got it with number 260, the compiler itself allocates the initial size of theStringBufferLen buffer to 260.
If the string length is less than 260, the StringBufferLen will print 260, not the actual string length!
And if the string length is greater than 260, then the actual string value is printed.
So, using the StringBufferLen function, with a string length of less than 260 characters, we won't get the actual string length, and will always get 260.
This must be an error.
As soon as the length exceeds 260 characters, we will get the real string length.
p.s. as the documentation is out of date it is very misleading.
That is, using the StringBufferLen function, with a string length of less than 260 characters, we will not get the actual string length, and will always get 260.
This must be an error.
As soon as the length exceeds 260 characters, we will get the real length.
Strictly speaking string length: StringLen and buffer length: StringBufferLen are rather rare functions. And in general they may not coincide.
That makes two at least questionable cases:
The executionresults show that the compiler acts contrary to logic:
The executionresults show that the compiler acts contrary to logic:
Preallocation size of buffers for strings is an internal matter of the compiler.
We will change the handling of strings many more times.