At present, only operator= is implemented, of the above. I was thinking about implementing a couple neat tricks.
1) Copy-on-write, as mentioned earlier. The ability to set variables to arrays simply with operator=. Only problem; writing will actually be slow, unlike if operator= simply copied the first element as it does in GM. 2) Array sub-arrays via operator.., which does not exist in C++. Basically, when you say varname[2..3], you get the contents of varname[2] and varname[3]. This could be handled by replacing [x..y] with .subArray(x,y). This requires only that the class being accessed has subArray defined, so user-implemented classes could easily provide the same functionality. (As an alternative, an overloadable function could be used, since C++ isn't so easily modified as, say, JavaScript. 3) Referencing vs. Hard copying; should subArray just copy the contents over, as subString does?
So, I was thinking about hijacking operator:=, which does not exist in C++. This could be used to indicate that data should be hard copied instead of perhaps just turn copying the entire array on via a setting. My original idea was to use := to indicate a hard copy, but such would be difficult without some class tinkering.
Yadda yadda, definitely considering implementing [..] as a wrapper to subArray, not sure what subArray should reference vs what it should copy. Fin.
|