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

Provide alias symbol name trait #17867

Open
dlangBugzillaToGithub opened this issue Jun 26, 2018 · 0 comments
Open

Provide alias symbol name trait #17867

dlangBugzillaToGithub opened this issue Jun 26, 2018 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Radu Racariu (@rracariu) reported this on 2018-06-26T14:13:35Z

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

Description

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.
@thewilsonator thewilsonator added the Feature:traits Relating to __traits label Dec 14, 2024
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

2 participants