The first step to detect common root for numbers.
The following codes will work after this commit:
check: func<T>(t: T, name: String){
if(t class name != name){
Exception new("Expected %s, get %s!" format(name, t class name)) throw()
}
}
mydouble: cover from Double
check(1.f + 1.l, "LDouble")
check(1.f + 1., "Double")
check(1.f + 1.f, "Float")
check(1l + 1.f, "Float")
check(1.f + 1. as mydouble, "mydouble")
In this patch, every "base type" (c type) has a score. For ooc types are cover from c types, we find the root and return the type with higher score.
This is not a really "good" solution, just as @shamanas said, we need to handle each case manually.
And also, Standard says that:
Otherwise, if one operand is a long int and the other unsigned int, then if a long int can represent all the values of an unsigned int, the unsigned int shall be converted to a long int; otherwise both operands shall be converted to unsigned long int.
I am not sure how to judge if a type can represent other at compile time....
The first step to detect common root for numbers. The following codes will work after this commit:
In this patch, every "base type" (c type) has a score. For ooc types are cover from c types, we find the root and return the type with higher score. This is not a really "good" solution, just as @shamanas said, we need to handle each case manually.
And also, Standard says that:
Otherwise, if one operand is a long int and the other unsigned int, then if a long int can represent all the values of an unsigned int, the unsigned int shall be converted to a long int; otherwise both operands shall be converted to unsigned long int.
I am not sure how to judge if a type can represent other at compile time....