nirum
nirum copied to clipboard
Make annotations richer
The current syntax of annotations is very limited:
- They can has only zero or one parameter.
- Their argument cannot be other than a string.
In order to make it usable for production (e.g. #130), make annotations richer through addition of the following features:
- [x] Multiple parameters (#190)
- [x] Keyword arguments (#190)
- [ ] Typed arguments
- [x] Strings, e.g.,
"foo"
- [x] Integers, e.g.,
123
(#267) - [ ] Type expressions, e.g.,
uuid
- [ ] References to union tags/enum members
- [ ] References to fields
- [x] Strings, e.g.,
In order to disambiguate annotations when multiple consumers (i.e. targets, runtimes) interpret them, we can make them exclusively allowed to have multiple keyword arguments or a single argument, not both e.g.:
@nullary-annotation // allowed 🙆🏻
type a = foo;
@unary-annotation("arg") // allowed 🙆🏻
type b = foo;
@single-keyword-annotation(x = "arg") // allowed 🙆🏻; keyword syntax is arbitrary for example
type c = foo;
@multiple-keywords-annotation(x = "arg1", y = "arg2") // allowed 🙆🏻
type d = foo;
@n-ary-annotation("arg1", "arg2") // disallowed 🙅🏻♂️
type e = foo;
we can make them exclusively allowed to have multiple keyword arguments or a single argument, not both
Or rather simply we can make them allowed to have only keywords, not positional arguments. Of course this approach need to break backward compatibility, which is less important for now.