So for a while now I've had this nagging feeling that I REALLY should be using "m". So far I haven't used it, I pass all the variables I need around all over the place, and I'm getting kind of tired of it. I have a LOT of info that I've broken down into a few main associative arrays which I pass to various functions, and I can draw info from them and change any values whenever I want.
Question - If I somehow put everything into "m", would that use more memory somehow? Not sure how garbage collector would handle stuff.
Question - How do I even do that?
The Brightscript Language Reference says:
A BrightScript object is an roAssociativeArray which contains function pointers. When a member function is called "from" an AssociativeArray, the special variable "m" is set to point to that AssociativeArray. "m" is accessible inside the called function to access other data in the AssociativeArray object.
I don't understand that at all (almost). :?
I thought I read somewhere that there are times you can't use "m"
The other relevant quote seems to be:
BrightScript does not support global variables. Except, there is one hard-coded global variable "global" that is an interface to the global BrightScript Component. The global component contains all global library functions. There is also a global context that can be accessed via the GetGlobalAA(). If in function scope and that function is not a method in an object, "m." also references the global associative array accessed with GetGlobalAA().
That too is a mystery to me, mostly. :shock:
Question - If I use "m" for "everything", it would create an additional layer for me, such as "
m.cAA.mainMenu.w[1]" vs "
cAA.mainMenu.w[1]". Everything would have this extra layer. Would that slow things down, since there is another dictionary lookup happening, or am I totally understanding that wrong?
As you can see I feel a bit lost on this.
😐