Is there any elegant julian way how to do what python could do with decorator?

I meant this (thickness is set to 1 but result is 2):

julia> plo(1,2; thickness=1, size = 2)
       ┌ Warning: `warn()` is deprecated, use `@warn` instead.
        ...
        WARNING: size is deprecated, use thickness
thickness is 2

Really thanks for your intention! :slight_smile:

I repeat that this is OP’s problem not mine, but it bring necessity to deal with default values in body. Which brings additional work to write good doc-string. And avoid to see (new keyword) parameters in tab-completer.

edit: my mistake (I am surprised a little) → nor tab-completer nor help nor methods show default values…

I know this is not your question, but here is another trick anyways!

julia> dep_kwargs = Dict(:size => :thickness);

julia> _plo(a, b; thickness=1) = 2;

julia> function plo(a, b; kwargs...)
          real_kwargs = Dict{Symbol, Any}()
          for (s, v) in kwargs
              if haskey(dep_kwargs, s)
                  warn("$(s) is deprecated use $(dep_kwargs[s]) instead!")
                  real_kwargs[dep_kwargs[s]] = v
              else
                  real_kwargs[s] = v
              end
          end
          return _plo(a, b, thickness=real_kwargs[:thickness])
       end
plo (generic function with 1 method)

julia> plo(1, 2, size=2)
WARNING: size is deprecated use thickness instead!
2

julia> plo(1, 2, thickness=2)
2
2 Likes