Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 9

Implicit Function Calls

I am confused by a section of code that I found in the videoplayer example provided by Roku. In the InitShowFeedConnection function that is in showFeed.brs there are the following lines:

conn.LoadShowFeed = load_show_feed
conn.ParseShowFeed = parse_show_feed
conn.InitFeedItem = init_show_feed_item

My understanding was that functions must be called with parenthesis after them and include the needed parameters [function(Param 1, Param 2,...)]. The last function in my above code does not have parameters but the first two do and they do not have default values.

Function load_show_feed(conn As Object) As Dynamic
End Function

Function parse_show_feed(xml As Object, feed As Object) As Void
End Function

How are these functions being called?
What is being used as the parameters for the functions when non are used in the call?

Thank you for your help and taking the time to read this.
0 Kudos
1 Reply
Level 8

Re: Implicit Function Calls

You are correct, to call a function, you must follow the function name with parentheses. The code you quoted is actually not calling any function, it is merely storing a "reference" to each function in an AssociativeArray (in other languages, a function reference is called a "pointer" to the function). The function is called by using the variable holding the function reference as if it were the function name. So after executing

conn.LoadShowFeed = load_show_feed

you could then say


to call the function. See also sections 4.10 and 4.11 in the Brightscript Language Reference.

0 Kudos