MetaEditor compiler optimization?

 
Slawa,

----------
MT4
----------
#define BUFFER "123456"

string a = BUFFER;
string b = BUFFER;

---------------------
c++ pesaudo code:
---------------------
void foo(char* pBuffer)
{
pBuffer[0] = 'X';
}

---------------
MT4 function:
----------------

void Test()
{
foo(a);
Print(a);
Print(b);
}

The output for both 'a' and 'b':
X23456
X23456

Which means: both 'a' and 'b' are using the same memory buffer!
Is it a compiler optimization to use same memory for constants(#define BUFFER "123456")?

Thanks
 
in the mql4 You cannot change strings "in place".
your "123456" belong to constant(!) string pool and both strings, a and b, refer to the same memory in the string pool
 
I understand that but this is not standard programming language behavior
#define section should be only exist in compile time not as constant in runtime.
string a = BUFFER;
string b = BUFFER;

should be compiled like (pseudo):
string a = new string(“123456”);
string b = new string(“123456”);

So “a” and “b” has different memory allocation!
Am I right? Will you change this in following versions?
Thanks, Ruby
 
what the standard do You mean? c++? or mql 4? please show me mql 4 standard
 
what the standard do You mean? c++? or mql 4? please show me mql 4 standard


I mean C++ standard
Reason: