Repository metrics
- Stars
- (8 stars)
- PR merge metrics
- (PR metrics pending)
Description
After it came up in several discussions I think it would be a good idea to make an actual proposal for this and see if we can push this in for the next version.
Basically, we have a bunch of use cases for some form of metadata notation:
- Assign types for the TS
- Mark methods as private in the WRE
- Mark methods and tests as deprecated
- Mark pieces of code as "should fail" or similar, to be able to define sanities containing invalid wollok definitions (so we can test what Wollok "is not").
- Help to internally represent stuff (like what is discussed on uqbar-project/wollok-ts#27)
and Annotations could be a great fit for this.
A simple approach could use the following syntax:
@parameterlessClassAnnotation
@parameterizedClassAnnotation(p1=5, p2=["text", true])
class C {
@fieldAnnotation
var f = 5
@methodAnnotation
method m() = 7
}
Annotations would be applied to the next non-annotation entity or member and simply store the annotated name along with any annotated parameters in the node. This allows for easy to extend and easy to ignore handling.
We don't necessarily need to provide an interface to read annotations, as long as we can access them in the backend implementations, but if we do, we could add that logic to the wre/mirror package, in order to keep the interfaces clean.
The main purpose for adding these would be to enrich the low-level definitions an allow a more standardized and cleaner cross-platform handling of many phases of the language. There would be no need to show annotations in class and should have no direct impact in the current syllabus and examples.
Once we agree on the general syntax and approach I can write some sanity tests for this to guide the implementation.