Skip to content

[spec/attribute] Improve UDA docs #4274

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions spec/attribute.dd
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ $(H2 $(LNAME2 uda, User-Defined Attributes))

$(GRAMMAR
$(GNAME UserDefinedAttribute):
$(D @ $(LPAREN)) $(GLINK2 expression, TemplateArgumentList) $(D $(RPAREN))
$(D @ $(LPAREN)) $(GLINK2 template, TemplateArgumentList) $(D $(RPAREN))
$(D @) $(GLINK2 template, TemplateSingleArgument)
$(D @) $(GLINK_LEX Identifier) $(D $(LPAREN)) $(GLINK2 expression, NamedArgumentList)$(OPT) $(D $(RPAREN))
$(D @) $(GLINK2 template, TemplateInstance)
Expand All @@ -1127,14 +1127,14 @@ $(GNAME UserDefinedAttribute):
)

A user-defined attribute is defined using:
* Compile-time expressions
* A named manifest constant
* A type name
* A type to instantiate using a compile-time argument list
* A list of one or more $(GLINK2 template, TemplateArgument)s
* A compile-time expression (matching the above grammar)
* A symbol identifier
* An expression (matching the above grammar) to invoke with an argument list at compile-time

$(SPEC_RUNNABLE_EXAMPLE_COMPILE
---
@(3) int a; // value argument
@3 int a; // value attribute
@("string", 7) int b; // multiple values

// using compile-time constant
Expand All @@ -1148,8 +1148,8 @@ struct Bar
{
int x;
}
@Bar() int d; // type instance
@Bar(3) int e; // type instance using initializer
@Bar() int d; // type instance attribute
@Bar(3) int e; // type instance attribute using initializer
---
)
$(P For `e`, the attribute is an instance of struct `Bar` which is
Expand Down Expand Up @@ -1232,7 +1232,7 @@ $(H3 $(LNAME2 uda-usage, Usage))
)

$(P
Whether the attributes are values or types is up to the user, and whether later
Whether the attributes are values or symbols is up to the user, and whether later
attributes accumulate or override earlier ones is also up to how the user
interprets them.
)
Expand Down