IssueRaiser

Allow decorators for functions as well

Decorators for classes, methods, and object properties are a really nice extension to the language. The only extra one I would _like_ to see is the ability to add decorators to function declarations: ``` @RunOnce function expensiveOperation() { return 1 + 1; } ``` de-sugars to: ``` var expensiveOperation = RunOnce(function expensiveOperation() { return 1 + 1; }); ``` --- This _suggests_ allowing decorators for any assignment, but I think that might be a bit much so I'm leaving it out of this PR: ``` // For the curious, that would allow constructs like this @RunOnce let expensiveOp = () => 1 + 1 // De-sugars to let expensiveOp = RunOnce(() => 1 + 1); ```

Posted by svieira on Mar 18, 2015, 9:12 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.7,500 issues0 comments

github (Other)

Allow decorators for functions as well

svieiraMar 18, 2015, 9:12 PM

Decorators for classes, methods, and object properties are a really nice extension to the language. The only extra one I would _like_ to see is the ability to add decorators to function declarations: ``` @RunOnce function expensiveOperation() { return 1 + 1; } ``` de-sugars to: ``` var expensiveOperation = RunOnce(function expensiveOperation() { return 1 + 1; }); ``` --- This _suggests_ allowing decorators for any assignment, but I think that might be a bit much so I'm leaving it out of this PR: ``` // For the curious, that would allow constructs like this @RunOnce let expensiveOp = () => 1 + 1 // De-sugars to let expensiveOp = RunOnce(() => 1 + 1); ```

Comments (0)

No comments yet. Start the discussion.

Comment on this issue