On Friday, 28 July 2023 at 12:20:05 UTC, Steven Schveighoffer wrote:
On 7/28/23 8:10 AM, Vijay Nayar wrote:
It might be possible to expand the grammar. It seems very specific to UDAs, as it doesn't just throw out `Expression` or whatnot. It probably has to do with the spot that it's in (declaration).

Yes, parsing arbitrary expressions after an `@` would result in this:
```D
void f(int x) @att in (x > 0) { }
```

Being parsed as:

```D
void f(int x) @(att in (x > 0)) { }
```

And things like `@3 + 3` don't look like they would be parsed as `@(3 + 3)`, it looks like `(@3) + 3`.

So the syntax as `@(expression)` to make it clear where the expression ends. Then there's `@identifier` and `@identifier(args)` as shorthand for common cases that do look clear. I recently added `@TemplateSingleArgument` so you can do `@"abc"` or `@3` as well. Perhaps the syntax can be expanded to allow `@a.b.c(d)` as well, as well as `@a.b.c!d`, though there's a risk of the rules getting convoluted.

Reply via email to