Assumptions: Based on the "Data Scoping" SDK article it sounds like "m" reference is used more like "private" in other languages (scope is available to the component but no other actor/instance), and "m.top" is used as a way to take "m" private references and expose them to parent ScreenGraph nodes (aka making them public?). This is just my guess after what I have read, but I'm looking to bring it back to one of the languages that I already understand... Can anyone help make the connection for me?
Second/Third (Bonus) Question:
Are there any good patterns/advice you can offer on when to use "m" versus "m.top"?
Are there any "gotchas" that I should be aware of for "m" vs "m.top" like:
As always, thank you to this forum for being very supportive (and not flaming/trolling) =P. At least to my first 3 posts!
To answer my own question (and failed), I have done the following
"m" is the private local associative array (the doc calls it "the m object reference") "top" a default element of m, node reference that refers to the component itself. m.top should be used sparingly and only when needed to set and observe fields from outside the node. you can use m to hold local data, functions, and all kinds of things (objects and sub-components) to help build up your screen experience. https://sdkdocs.roku.com/display/sdkdoc/SceneGraph+Data+Scoping oh you listed that one, yeah it's not very deep. Basic rule of thumb, always use m and never m.top unless you have to.
`m` is equiv to 'this' or `self` in a lot of other languages. `m` is closed/private to external agents. `m.top` is part of object creation managed by BrightScript/RSG such that anything put into (or made as an entry/attribute/field/property w/e you want to call it) `m.top` automatically becomes part of the objects public scope and thus m.top will allow external agents access to read/edit and possibly expose implementation details of said object.
A different way to say it, but a way that I think I understood what you said (makes sense in my head). Did I express anything that demonstrates I obviously missed the mark?
`m.top` is part of object creation managed by BrightScript/RSG such that anything put into (or made as an entry/attribute/field/property w/e you want to call it) `m.top` automatically becomes part of the objects public scope and thus m.top will allow external agents access to read/edit and possibly expose implementation details of said object.
Yes though one point is that you can't just put anything into top; being that top is a node, you can append children nodes to it (that would usually cause something to show up on screen) or set fields on it, setting fields isn't automagic, the field has to be defined in component's interface fields or added with addField (or be a default field on node such as "id").
It's important to understand the difference between the types "node" and "associative array".; m is the latter and you can just put anything onto it, m.top is the former and has fields and child nodes.