arjan / decorator

Function decorators for Elixir
MIT License
385 stars 20 forks source link

Multiple decorators order #49

Open antonmi opened 3 years ago

antonmi commented 3 years ago

Hey guys! Thank you for the great tool! I'm experimenting a bit with multiple decorators like:

@decorate foo()
@decorate bar()
@decorate baz()
def hello() do
  :world
end

Intuitively I expect baz to decorate hello, then bar decorates baz and hello, then, finally foo decorates all of them bar, baz, hello.

But for some reason, there is Enum.reverse here https://github.com/arjan/decorator/blob/7adc22fe6b8a7865ec461d850e3ac735eda33c8d/lib/decorator/decorate.ex#L127 so the execution is the opposite: baz decorates bar, foo, hello.

What is the intention of reversing the order? And do you recommend applying several decorators? Thank you!