Open
Description
It's become fairly common for people to write code like this:
n = Int(length(items))::Int
This is kind of verbose and redundant. I had always hoped that we might add type signatures for generic function such that the ::Int
part is implied by the signature of Int(...)
but that seems unlikely in the Julia 1.x timeframe. Perhaps a more pragmatic solution would be to have syntax sugar for the "convert and assert" pattern. We could have
n = length(items) as Int
# means this:
n = Int(length(items))::Int
Of course, in this case, I think you could just as well write n::Int = length(items)
but that's not always doable.