Hi,
Max strings are 'immutable', meaning they cannot be modified once created. This is really what makes them strings, and not just funky short arrays.
This does in fact prevent a lot of unnecessary copying. Consider this code:
Local t$="Hello"
DoSomething( t )
Assert t="Hello"
...currently, this code is guaranteed not to cause an exception since nothing can modify the string.
However, if string modification were allowed, you'd have to do something like...
Local t$="Hello"
DoSomething( t.Copy() )
Assert t="Hello"
...unless of course you knew before hand that DoSomething() didn't modify its argument. However, this is not generally the case.
In fact, you'd have to do a lot of copying - when calling functions, when storing string in fields, globals etc - 'just in case' the original string was later modified.
All in all, I believe the current system makes dealing with strings much easier and ultimately faster.
Max strings are 'immutable', meaning they cannot be modified once created. This is really what makes them strings, and not just funky short arrays.
This does in fact prevent a lot of unnecessary copying. Consider this code:
Local t$="Hello"
DoSomething( t )
Assert t="Hello"
...currently, this code is guaranteed not to cause an exception since nothing can modify the string.
However, if string modification were allowed, you'd have to do something like...
Local t$="Hello"
DoSomething( t.Copy() )
Assert t="Hello"
...unless of course you knew before hand that DoSomething() didn't modify its argument. However, this is not generally the case.
In fact, you'd have to do a lot of copying - when calling functions, when storing string in fields, globals etc - 'just in case' the original string was later modified.
All in all, I believe the current system makes dealing with strings much easier and ultimately faster.