Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin types could be usable as UDA, without being enclosed in parens #19651

Open
dlangBugzillaToGithub opened this issue Dec 22, 2019 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

basile-z reported this on 2019-12-22T17:32:13Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=20464

CC List

Description

Minor enhancement suggestion

---
template BasicTypeUDA(T)
{
    @T(0) int v1;
    @int(0) int v2; // not accepted by the parser but this is the same as v1 attribute when  `T` is an `int`.
}

alias WithInt = BasicTypeUDA!int;
---

possible by simplifying the current rule for UDA this way:

UserDefinedAttribute:
    @ ( ArgumentList )
-    @ Identifier
-    @ Identifier ( ArgumentListopt )
-    @ TemplateInstance
-    @ TemplateInstance ( ArgumentListopt )
+    @ BasicType
+    @ BasicType ( ArgumentListopt )

since BasicType covers Identifier, TemplateInstance, builtin types and even more. (https://dlang.org/spec/declaration.html#BasicType)

The @ guarantees that parsing will not become ambiguous.
This would simplify a bit the language by generalizing the use of the construction syntax, although we all know that `@Type(args)` is just the short for `@(Type(args))`.
@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2021-09-28T04:54:09Z

*** Issue 22338 has been marked as a duplicate of this issue. ***

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant