-
Notifications
You must be signed in to change notification settings - Fork 127
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
Specification Proposal #66
Comments
@silkentrance I would fully support this change (not that I have any say in the matter mind you :) This represents the most elegant solution to the 'parentheses problem' I think. I have to admit I always have trouble reading those syntax descriptions... I would expect the literal parentheses characters Anyway, if the syntax means what I think it does I fully agree it would be much better than I think this proposal could actually be combined with the one from #65 could it not? Because I think that being able to intercept the decoration process would be valuable in and of itself. |
So I'm assuming with this the arguments are not being captured. This is simply restricting the grammar to allow generators to be decorated, right? Which would make sense. If the arguments are being captured at the end, I would advise against it. Simply because the arguments passed in at the end should match 1:1. That's what led me to believe So IMO, the result of the expression should be considered the decorator just as it was with |
@lukescott arguments passed to a parameterizable decorator are captured by
The other issue you are referring to is implementation / runtime specific and is not part of the grammar. It simply deals with the available notations one can use when using decorators. |
Given the new spec proposal, it will remain a LeftHandSideExpression. It seems that the fault lies in the parser transformer, in that case babel. |
No need to keep this open any longer. Must try convince babel to work as expected. |
ROUTE 66 - WORK IN PROGRESS
With babylon having problems parsing decorated generator functions it seems that the current specification of a decorator is too lax and by that overly complex.
While it is surely nice to have something like
it is way too much considering the common and thus standard use cases for decorators, which are
and also considering that one is currently unable to
due to the fact that the current specification is based on
LeftHandSideExpression
, which for example causes the babylon parser to parse this asHow about limiting decorators to specialized variants of CallExpressionS and MemberExpressionS, which are presumably the most used forms of decorators. And, with that in place, the babylon parser could be fixed in order to support decoration of generator methods.
PROPOSAL
MemberReference [Yield] :
IdentifierName [?Yield]
MemberReference [?Yield] [ Expression [In, ?Yield] ]
MemberReference [?Yield] . IdentifierName [?Yield]
DecoratorCallExpression [Yield] :
MemberReference [?Yield] Arguments [?Yield]
DecoratorCallExpression [?Yield] Arguments [?Yield]
DecoratorCallExpression [?Yield] . IdentifierName [?Yield]
DecoratorCallExpression [?Yield] [ Expression [In, ?Yield] ]
Decorator [Yield] :
@DecoratorExpression [?Yield]
DecoratorExpression [Yield] :
DecoratorCallExpression [?Yield]
MemberReference [?Yield]
The above will allow us to
and so on.
RATIONALE
The current specification of LeftHandSideExpression is way too lax and will prevent users from decorating generator methods, see the referenced babylon issue above.
With Angular2 using TypeScript, the available docs do present use of above depicted two use cases only. And even in Python and frameworks thereof, you will never see anything more complex than the above two use cases. The same with annotations in Java or similar such languages, where these two use cases have been made a fixed idiom of the language, which is actually true for Python, also.
@lukescott, @wycats, @loganfsmyth, @jayphelps, @Download You have already discussed this in #23 and I think that we should discuss this further.
The text was updated successfully, but these errors were encountered: