Bug 20464 – builtin types could be usable as UDA, without being enclosed in parens

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-12-22T17:32:13Z
Last change time
2024-12-13T19:06:35Z
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#19651 →

Comments

Comment #0 by b2.temp — 2019-12-22T17:32:13Z
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))`.
Comment #1 by b2.temp — 2021-09-28T04:54:09Z
*** Issue 22338 has been marked as a duplicate of this issue. ***
Comment #2 by robert.schadek — 2024-12-13T19:06:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19651 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB