-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requeststypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Description
It's become fairly common for people to write code like this:
n = Int(length(items))::IntThis 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))::IntOf course, in this case, I think you could just as well write n::Int = length(items) but that's not always doable.
Heptazhou and impact-basin
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requeststypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch