It should be possible to annotate nodes, properties,... to add extra metadata and behaviour to the existing QML model in an extensible way that would need minimal grammar changes.
The main drawback of an annotation with respect to a keyword is that typos will not be catched if we allow undeclared annotations.
If annotation have to be declared somewhere, than that limitation is not there.
I would go with @QmlLikeObject for the annotations, and attach all the annotations to the first non annotation line, be it a type, property, binding, assignment, Behaviour,... and make them available in the DOM API.
I would not put them in comments, and they should refer to the type, property, function,… immediately after all the annotations.
In the DOM model then every type, property,… would have a list annotations.
The reason to use this syntax are the following:
- minimal changes to the grammar
- flexible (can cover basically all use cases I can think of)
- The annotations can be declared without introducing new syntax (we could use @Annotation in declaring them, or they could have a separate file extension)
- we can provide tooling/typo detection,… by requiring all annotations to be declared
- documenting can be done in a similar way to QML
With it the example given by Thomas could become adding the following qml annotation declarations
'Extra' (Annotating node with extra arbitrary properties)
'Invisible' (Item is invisible in editor)
'Lock' (Item is locked in editor)
'InternalId' (internal id)