Explicit type annotation in document for function in julia #50686
hungpham3112
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
AFAIK, julia is famous for its rich type system so I expected that Julia document is where I should rely on. Every time when searching the function with help mode I want to know what datatype I could get after I use one function, for example:
My expected is something like this:
or
The function sum is popular so it's not maybe good example for imagination, what about
coalesce
:The function name:
coalesce
is ambiguous in the name for beginner. It will be better if something similar:coalesce(x::Vector{Int64}...) -> Union{Int64, missing}
with this explicit annotation I know exactly what I'm doing. Is there any part of julia document as my expectation? Yes,
map
:maybe
N-array
is not actually a type it could beMapArray
but at least I know it return something so my thinking workflowinput -> map() -> output1 -> coalesce -> result
will be smooth btw.To compare current julia state we can see our nearest neighborhood:
Python
. According to typing module in python where type annotation is encourage but not default option:or even more
explicit
like rust:After all of that, I'm not sure if it's only julia current state, in the future we could have better document and function in the core will have explicit type annotation so newcomers can understand code better. I know type annotation is only optional, you can write function with or without it but the changing in core function as a leader so the ecosystem will look at that and changing more. so we will have what actually
strong type system
in not only the implementation and documentation but also encourage people to write a better code.My thought is personal so it maybe bias or limit, perhaps I'm missing insight about the julia core implementation or julia actually in the state where document doesn't good enough.
Beta Was this translation helpful? Give feedback.
All reactions