Reverse Dereferencing?

BlitzMax Forums/BlitzMax Programming/Reverse Dereferencing?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

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.