You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@sebmck wanted me to verify this over here first, since the spec desugaring examples imply it, but it's non-obvious and Babel currently doesn't seem to follow the implied behavior. I originally noticed this over in #20 but it's separate.
Decorator functions are applied to descriptors bottom-up and are thought of as wrappers. My question is about the order of evaluation of the decorator expression themselves. Are they also meant to be evaluated bottom-up, or top-down? In Python for example, while decorators are applied bottom-up, the expressions are evaluated top-down. To demonstrate:
function fn(arg){
console.log('evaluated', arg);
return function(){
console.log('called', arg)
};
}
class Example {
@fn(1)
@fn(2)
method(){}
}
would the expected output be
evaluated 1
evaluated 2
called 2
called 1
or
evaluated 2
evaluated 1
called 2
called 1
Babel's current implementation results in #2, which is the opposite of Python's behavior, and also the opposite of the desugared examples, e.g.
fn(1)(fn(2)(...))
which will execute fn(1) first, but will call the result of fn(2) first.
The text was updated successfully, but these errors were encountered:
+1 for this from me, the order by which the decorators are applied is important and should be bottom up as @loganfsmyth did implement in the interim legacy decorators plugin, which I think should be the basis for any future work.
@sebmck wanted me to verify this over here first, since the spec desugaring examples imply it, but it's non-obvious and Babel currently doesn't seem to follow the implied behavior. I originally noticed this over in #20 but it's separate.
Decorator functions are applied to descriptors bottom-up and are thought of as wrappers. My question is about the order of evaluation of the decorator expression themselves. Are they also meant to be evaluated bottom-up, or top-down? In Python for example, while decorators are applied bottom-up, the expressions are evaluated top-down. To demonstrate:
would the expected output be
or
Babel's current implementation results in
#2
, which is the opposite of Python's behavior, and also the opposite of the desugared examples, e.g.which will execute
fn(1)
first, but will call the result offn(2)
first.The text was updated successfully, but these errors were encountered: