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
Unfortunately, it is quite difficult to perform type testing on a function or method. The primary reason for this is that JavaScript does not embed enough type information into function pointers. For example, consider the following:
type Sized is { int value }
type SizeGetter is function(Sized) -> int
type SizeSetter is function(Sized,int) -> Sized
function f((SizeSetter|SizeGetter) x) -> int:
if x is SizeGetter:
return 1
else:
return 0
This currently translates into the following JavaScript:
Unfortunately, as we can see, typeof val could at best return function in this case. To go beyond this, we need to embed some kind of information into the function pointer itself. Or, alternatively, consider a different way of implementing type tests (e.g. tagging).
Activity