-
Notifications
You must be signed in to change notification settings - Fork 214
Allow functions to be used directly as metadata annotations #3210
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
Comments
Metadata is specified to be a reference to a constant variable, or an invocation of a constant constructor, and everything else is a compile-time error. I'm not quite sure why the rules are so strict (these rules haven't been changed recently, if ever), and you have already mentioned that the function object Syntactically, an expression that denotes a statically resolved function is already covered by the grammar rule about metadata. So we should be able to introduce this generalization without breaking anything. |
Only change I remember was to allow type arguments to constructor invocations. If we allow constant function tear-offs, we should consider whether to allow instantiated function tear-offs (with constant type arguments). That won't actually complicate the grammar much, since we already accounted for all the problems when introducing record types:
It should just work. We already allow If we allow static functions, we can also allow constructor tear-offs, which would mean allowing So, something like: <metadatum> ::=
<identifier> <typeArguments>?
| (<typeIdentifier> '.')? <typeIdentifier> <typeArguments>? ('.' <constructorName>)? (NO_SP <arguments>)?
<constructorName> ::= <identifier> | 'new' |
+1 |
I believe you're correct. |
Uh oh!
There was an error while loading. Please reload this page.
I haven't actually looked at the language spec to know for sure whether this is considered a bug or not, but this definitely seems like some unwanted behavior. Filing here instead of
sdk
since I'm guessing it is due to the language specification.Using functions as metadata annotations will be useful for when static metaprogramming roles around.
The text was updated successfully, but these errors were encountered: