You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.
The canonical example of JS interop is console.log, which returns nothing. We have a test showing that we can coerce console to Number if need be.
But what about handling return values from calls to JS functions? Since Roy doesn't have null or undefined, how do we handle the case where we get one of those values back?
One approach would be to include something along the lines of JSOption in the core (or stdlib?), and wrap all JS return values in it:
dataJSOptionvalue=Somevalue | Null | Undefined
match strFromJsFunction
case (Some (Str str)) = console.log str
caseNull= console.log"Got back null"caseUndefined= console.log"Got back undefined"
On the flip side, there's also the question of how to interact with JS APIs that require passing null or undefined under certain circumstances. One approach would be to give JSOption special treatment when making calls out, having Null compile to just the JS literal null, Some foo compile out to just foo, etc. I'm not a fan of special treatment in general, but it's at least a starting point for discussion.
Thoughts?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The canonical example of JS interop is
console.log
, which returns nothing. We have a test showing that we can coerceconsole
toNumber
if need be.But what about handling return values from calls to JS functions? Since Roy doesn't have
null
orundefined
, how do we handle the case where we get one of those values back?One approach would be to include something along the lines of
JSOption
in the core (or stdlib?), and wrap all JS return values in it:On the flip side, there's also the question of how to interact with JS APIs that require passing
null
orundefined
under certain circumstances. One approach would be to giveJSOption
special treatment when making calls out, havingNull
compile to just the JS literalnull
,Some foo
compile out to justfoo
, etc. I'm not a fan of special treatment in general, but it's at least a starting point for discussion.Thoughts?
The text was updated successfully, but these errors were encountered: