-
Notifications
You must be signed in to change notification settings - Fork 1.7k
reflective access to metadata #6614
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
Added Area-Language, Triaged labels. |
Added C1 label. |
this is library-mirrors right? cc @gbracha. |
This comment was originally written by [email protected] I think https://code.google.com/p/dart/issues/detail?id=8493 is a duplicate? |
Issue #8493 has been merged into this issue. |
Removed Priority-Medium label. |
This comment was originally written by [email protected] I understand that this requires support from VM, is that a problem ? |
It's not a problem. I'm just trying to communicate the steps this requires. Whether annotations are useful when they are not available at runtime depends on the usage scenario, but I appreciate that you need them at runtime. |
This comment was originally written by [email protected] How can I use them other than in runtime ? |
There are people who want to use them at compile time, and they can use dart2js to parse the code and collect the relevant data. It isn't your use case, but it is not uncommon. |
This comment was originally written by [email protected] for an example of compile time annotation usage see the use of web-ui's @observable also, thanks for the work on this. im really looking forward to runtime access!! |
cc @iposva-google. |
So the proposed API for this would be to add the following to DeclarationMirror /** A map would be nice, but metadata does not have a unique name. We could have a map if each entry was a list., i.e., The key would be the symbol for name of the constructor or variable used as metadata. |
This comment was originally written by [email protected]
|
Responding two comment 15: This is an extension to the introspection API. It does not allow programs to be modified, only to be observed. So the answer to the first question is that the list (or map) will be immutable. As for the second item (which I may have misunderstood): metadata appears on source code, and is associated with declarations. So it makes no sense to query instances. If you want data on instances, put it in them; it's not meta data, just data. |
This comment was originally written by [email protected] Thanks for the response(s). If this is purely introspection than the second item is inherently ruled out, but FWIW I was referring to 'attribute redirection' as described here: |
This comment was originally written by [email protected] Or 'metadata substitution', I'm not up to snuff with their terminology. But this particular method has key uses in designers / property grids: |
Ross, When we have mirror builders, one will be able to change the metadata on existing declarations. Mirror builders will probably not be a universally available though, because supporting them on dart2js is likely to be much too costly. |
This issue was originally filed by [email protected]
From the language specification (0.12) :
"Metadata can be retrieved at runtime via a reflective call, provided the annotated program construct p is accessible via reflection.
Reflective access to metadata is not yet implemented as of the M1 release."
I am opening this issue so that we have something to track regarding this feature.
thanks a bunch!
The text was updated successfully, but these errors were encountered: