Forum Discussion
EnTerr
9 years agoRoku Guru
"jaxim" wrote:
The following is what I tried to do but the methods referenced in the associative array return as invalid:
[...]
What am I doing wrong?
You are doing nothing wrong. It's just that "Roku Scene Graph" imperial new clothes do NOT allow first-class functions. That is, RSG cannot have fields of type function. And to add insult to the injury, RSG does not throw error or a warning - it silently strips them from anything you store in a field and pretends nothing happened.
Yes, you are quite right to expect functions should be passable around like in most all programming languages. And no (you are welcome to try) - you cannot out-smart RSG and store them deep within a nested array or associative array (you are welcome to try) - it will "find" them and it will strip them. There is no way around that. See the list of the RSG-approved field types here
I have been talking about function fields for a while, e.g. see viewtopic.php?f=34&t=95412 and viewtopic.php?f=34&t=95290. I am not sure i was understood correctly by the intermediaries re what "first-class function" means and why it matters - but by now i am sure it will not be coming in the next firmware version... and possibly never.
There is a distinction to make, lest the wrong thing be blamed: this is not a Roku language issue - it is a library issue!
Brightscript does support first-class functions just fine, you can assign them as variables, pass them around, use them as m-methods.
Rather, 'tis the RSG library that does not support functions properly.