EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2016
12:48 PM
`invalid` does not autobox?
This is "meta" by my own standards 🙂 - but shouldn't `invalid` auto-box to `roInvalid` as needed, as the rest of the value-types do?
i see that roInvalid implements ifToStr, i presume to allow calling toStr() on all objects and get something printable w/o worrying to check for special cases first. i don't even know why roInvalid exists in the first place (a guess - so it can be stored in roArray, historically?) - but all other primitive types already tend to auto-box themselves "as needed" and invalid doesn't. Shouldn't it, too?
I am not sure which way is right, just pointing out what seems like a discrepancy.
i see that roInvalid implements ifToStr, i presume to allow calling toStr() on all objects and get something printable w/o worrying to check for special cases first. i don't even know why roInvalid exists in the first place (a guess - so it can be stored in roArray, historically?) - but all other primitive types already tend to auto-box themselves "as needed" and invalid doesn't. Shouldn't it, too?
I am not sure which way is right, just pointing out what seems like a discrepancy.
3 REPLIES 3


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2016
11:11 AM
Re: `invalid` does not autobox?
"EnTerr" wrote:
... all other primitive types already tend to auto-box themselves "as needed" and invalid doesn't. Shouldn't it, too?
The behavior is intentional. Invalid is invalid.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2016
11:57 AM
Re: `invalid` does not autobox?
"RokuKC" wrote:
The behavior is intentional. Invalid is invalid.
Hmm, but:
Brightscript Debugger> ? getInterface(invalid, "ifToStr")
<Interface: ifToStr>
Brightscript Debugger> ? (invalid).toStr()
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in $LIVECOMPILE(254)
So i can get ifToStr on invalid "no problema" but get spanked (runtime error "heck" :mrgreen:) if trying to use it.


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2016
03:07 PM
Re: `invalid` does not autobox?
"EnTerr" wrote:
[code]Brightscript Debugger> ? getInterface(invalid, "ifToStr")
<Interface: ifToStr>
Yes, I can see why that is confusing. GetInterface() is defined as taking an object, so it boxes whatever is passed to it.