round(1.1) --> 1.0
round(Int, 1.1) --> 1
works, but not
sqrt(Complex, -1)
acos(Complex, 1.1)
...
and other inverse trigonometric functions where the real domain is limited. In these cases the desired result is obtainable with
sqrt(-1 + 0m) --> 0.0 + 1.0im
acos(1.1 + 0im) --> 0.0 - 0.4435682543851153im
which is concise, but feels a bit “hackish” or FORTRAN-like, or
sqrt(Complex(-1)) --> 0.0 + 1.0im
acos(Complex(1.1)) --> 0.0 - 0.4435682543851153im
where the intention is perhaps clearer but “object-oriented” syntax rather than "functional’.
Another candidate is
s=[2^x for x in 58:62] # <--- some large integers
sum(x -> x*x, s) # --> 0, incorrect result, instead
sum(BigInt, x -> x*x, s) # would give the right result, but does not work
sum(x -> BigInt(x)*x, s) # is correct and equivalent, but less "nice"
So generally an optional first type argument would indicate that the return should be of this type, but also that the function will try to “do the right thing” to get the correct result. What exactly this means depends on the function.
Is this good or bad? Are there more candidate functions which usefully could be updated to support an optional first type argument?