nirum-lang / nirum

Nirum: IDL compiler and RPC/distributed object framework for microservices
https://nirum.org/
GNU General Public License v3.0
121 stars 28 forks source link

Make annotations richer #178

Open dahlia opened 7 years ago

dahlia commented 7 years ago

The current syntax of annotations is very limited:

In order to make it usable for production (e.g. #130), make annotations richer through addition of the following features:

dahlia commented 7 years ago

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;
dahlia commented 7 years ago

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.