When should a function include an explicit return statement in Julia?

The Blue Style guide recommends always using return in long-form functions definitions.

I like the consistency and clarity of that convention.


Technically speaking, you do have to use the return keyword if returning CodeInfo from a @generated function. Due to a long standing bug https://github.com/JuliaLang/julia/issues/25678 Which comes up if you are trying to implement Cassette style complier passed or similar (see a blog post I wrote on that)

With that said, this is so incredibly obscure that I really hesitate to make this answer. For all but dozen or so people who will ever try and do that kinda thing, The presence of return or not in the last statement is purely a mater of style.

Tags:

Julia