Skip to content

Commit

Permalink
add __traits(fullyQualifiedName)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 22, 2023
1 parent c0befca commit bc481b5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions spec/traits.dd
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ $(GNAME TraitsKeyword):
$(RELATIVE_LINK2 hasCopyConstructor, $(D hasCopyConstructor))
$(RELATIVE_LINK2 hasPostblit, $(D hasPostblit))
$(RELATIVE_LINK2 identifier, $(D identifier))
$(RELATIVE_LINK2 fullyQualifiedName, $(D fullyQualifiedName))
$(RELATIVE_LINK2 getAliasThis, $(D getAliasThis))
$(RELATIVE_LINK2 getAttributes, $(D getAttributes))
$(RELATIVE_LINK2 getFunctionAttributes, $(D getFunctionAttributes))
Expand Down Expand Up @@ -1442,6 +1443,43 @@ export
public
)

$(H3 $(GNAME fullyQualifiedName))

$(P Takes one argument, which can be a type, expression, or symbol, and returns a string.)

$(UL
$(LI A $(D type) returns a string representing the type.)
$(LI A $(D expression) returns a string representing the type of the expression.)
$(LI A $(D symbol) returns a string representing the fully qualified name of the symbol.)
)

$(SPEC_RUNNABLE_EXAMPLE_COMPILE
---
module plugh;
import std.stdio;

void main()
{
auto s = __traits(fullyQualifiedName, int);
writeln(s);

auto t = __traits(fullyQualifiedName, 1.0);
writeln(t);

auto u = __traits(fullyQualifiedName, t);
writeln(u);
}
---
)

Prints:

$(CONSOLE
int
double
plugh.main.t
)

$(H3 $(GNAME getProtection))

$(P A backward-compatible alias for $(GLINK getVisibility).)
Expand Down

0 comments on commit bc481b5

Please sign in to comment.