New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decorators #996
Comments
Try here http://githubissues.heroku.com/#jashkenas/coffee-script/ and switch to Closed before searching for |
Yep, thanks, found -- a very old issue (enchantment, wontfix): https://github.com/jashkenas/coffee-script/issues/issue/76 Yeah, a (simple/extended) I.e. So, if it was decided so long time ago, I think this ticket can be closed also. Dmitry. |
Here's a simple wrap for you:
And here's how you can use it:
Or, something a little more advanced:
|
Yes, as already was mentioned, a wrap util can (and always could before) be implemented in the language itself. The talk was only about a syntactic sugar for it. |
Well this is basically the end of coffeescript if they don't start supporting modern features like this. |
Death rumors again? |
Hello, Passing by from codetriage.com and trying to help sort (trier?) issues. Since this is an ES6 proposal as well, it soon might not be considered an extension anymore. Here's an article that seems to imply decorators are already possible in ES6 Only problem I see is choice of a new character for denote a decorate, because @ has already been taken. Since this was reopened maybe adding the (If I'm doing this triage wrong, do tell. I'm here to learn :) ) |
It wasn't reopened on purpose. It was just closed so long ago, posting a comment removed the "closed" tag. |
Unfortunately, the search by issues is currently broken, so cannot check whether such a feature was already proposed.
What about to have a bit sugar for AOP in respect of decorators or (pre/post) annotations?
Python has a common strategy of decorating an annotating methods. E.g.:
Thus, a syntax can be chosen any (since
@
is used in Ruby-style for "instance variables"). Python uses such decorators not only to wrap some functions (i.e.@foo def bar ...
is just a sugar forbar = foo(bar)
) but also to change a semantics of some methods -- e.g.@classmethod
decorator, etc.Additional info for Pythons decorators: http://www.python.org/dev/peps/pep-0318/
Also, besides the Python's common decorators,
pre-
andpost-
annotations
can be considered.E.g. (abstract syntax):
I.e. before entering the
handleRequest
firstcheckArguments
andvalidatePost
methods should be called. Then thehandleRequest
itself and after thatformatResponse
.Thus, methods-annotations should accept/return a data of a special format. If e.g.
checkArguments
isn't passed, it should either throw or return a specialerror
data (a signal that other annotation in chain shouldn't continue). In the successful passing, it just returns handled data which are passed next to the following annotation/decorator.Dmitry.
The text was updated successfully, but these errors were encountered: