"renojim" wrote:
I think you're forgetting that there's two "m"s - the global "m" and the "m" that's akin to "this" for an object. I suspect that btpoole is mixing them. I don't think you can get to the global "m" from within a function that is part of an object.
I did not forget that - but in neither of those two cases you'll get "type mismatch" as mentioned above. `m` would have to been mutilated somehow first.
A bit to the side, discussion of `m`: there are not 2 different M's as such. Rather, on function invocation the local variable `m` gets pre-set to one of 2 kind of AA's, depending on
how it got called:
BrightScript Debugger> f = function(): return m: end function
BrightScript Debugger> ? f()
port: <Component: roMessagePort> 'outer M
BrightScript Debugger> obj = { g: f } : ? obj.g()
g: <bsTypedValue: Function> 'M = obj
BrightScript Debugger> h = obj.g : ? h()
port: <Component: roMessagePort> 'outer M
BrightScript Debugger> ? obj.g(), (obj.g)(), box(obj).g(), box(obj.g)() 'pop quiz
For evil hackers, one can modify it at own risk (e.g. `m = GetGlobalAA()` at the very beginning of the fn will guarantee `m` is always "global", no matter where the function is).