I disagree that this is less OO than what @mauro3 showed (regardless of what the term OO actually means). The closure you show in your code is implemented as a struct
storing a
. The only real difference between the two examples is that yours is one line shorter but produces intermediate outputs which might be less legible and shouldn’t be dispatched on.
julia> dump(mul)
#13 (function of type var"#13#14"{Int64})
a: Int64 2
edited to make the tone seem less aggressive (did not mean to be aggressive)