According to https://developer.garmin.com/connect-iq/core-topics/mobile-sdk-for-android/ :
Java long, Long => Monkey C Integer*, Long (If the value of the long is small enough to be represented as an integer, it will be converted to save space.)
Java double, Double => Monkey C Float, Double (If the value of the double is within 5 matching significant fractional digits of the nearest float, it will be converted to a float to save space.)
So what does this mean on the receiver's side?
Let's say in Java I'm sending:
List<Object> message = new ArrayList<>();
message.add(1L);
message.add(1d);
List<Long> longs = new ArrayList<>();
longs.add(1L);
longs.add(98765432109876L); // Note: greater than Integer.MAX_VALUE: 2147483647
longs.add(3);
message.add(longs);
and in Monkey C I'm reading:
var data as [Long, Double, Array<Long>]?;
function onPhone(msg as Communications.PhoneAppMessage) as Void {
data = msg.data as [Long, Double, Array<Long>];
var isItLong = data[0];
var isItDouble = data[1];
var whatsInThisArray = data[2];
}
How should I treat in Monkey C the values that in the Java side are long or double? Should they be considered Number or Long, Float or Double respectively? Does it mean that I should check each one of them with instanceof?
Note that the above question intentionally doesn't mention type checker, because as far as I understand the problem is deeper than that, but when using strict type checker, then it's more obvious.