lock_4815162342
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2014
01:30 PM
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:
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.
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.
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.
1 REPLY 1

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2014
02:56 PM
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
you could then say
to call the function. See also sections 4.10 and 4.11 in the Brightscript Language Reference.
--Mark
conn.LoadShowFeed = load_show_feed
you could then say
conn.LoadShowFeed()
to call the function. See also sections 4.10 and 4.11 in the Brightscript Language Reference.
--Mark