Coming to Julia from Python I am looking for something that sort of sets the standard for idiomatic Julia. In the Python world there is PEP 8 -- Style Guide for Python Code here. I am looking for the equivalent in the Julia world.
For example, the Python statement on use of return
at above link is:
Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable).
The closest I have found to a PEP 8 in the Julia world is the Style Guide section of the Julio 1.0.0 documentation here. I did not see a discussion regarding the use of return
there.
Question: Is there something more that someone can steer me to?
Question: Is it considered idiomatic Julian to always use the return
reserved word at the end of a function?
return
statements (I sometimes omit it in very short methods). I find things are too implicit otherwise. My function might actually be subtlely type unstable. – carstenbauernothing
, 10 lines apart, and one isreturn nothing
and the other isnothing
. Thanks for the pointer. I like the comments here suggesting that an explicitreturn
should be used most of the time. – Julia Learnerreturn
. Ordinary long-form functions: alwaysreturn
. I find implicitreturn
s disorienting, and always keep thinking that it must be a statement that has some invisible side-effect, before realizing, 'oh, I guess it's just areturn
statement'. But it is in very common use, even among core devs, unfortunately. – DNF