[Issue 19029] New: Provide alias symbol name trait

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 26 14:13:35 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19029

          Issue ID: 19029
           Summary: Provide alias symbol name trait
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: radu.racariu at gmail.com

Currently there is no way to get the name of the alias for a symbol type.

For example the following:
===
void main()
{
    import std.traits;
    size_t s;

    pragma(msg, typeof(s).stringof);
    pragma(msg, mangledName!(typeof(s)));
    pragma(msg, mangledName!s);
}
===
Prints
---
ulong
m
_D9onlineapp4mainFZ1sm
---

For code generation porpoises (eg. generate C wrapper code) there is no way to
get the type of `s` as `size_t` because `size_t` is an alias.

A new trait, `__traits(aliasName, symbol)`, could be used to retrieve the alias
name for a symbol type.

This trait will return the name of the concrete type if the symbol type is not
an alias.

--


More information about the Digitalmars-d-bugs mailing list