Trying to get current function name results in compiler error with __traits
Neia Neutuladh
neia at ikeran.org
Fri Dec 7 04:27:11 UTC 2018
On Fri, 07 Dec 2018 02:37:34 +0000, Arun Chandrasekaran wrote:
> I'm trying to get the current function name and apparently the commented
> line errors out.
>
> What am I doing wrong?
Referring to nested functions is weird.
Dotted identifiers let you traverse aggregates. Modules, C++ namespaces
(ugh), enums, structs, identifiers, unions, that sort of thing. They
*don't* let you traverse functions to refer to symbols defined inside
those functions.
*Separately*, nested functions have names that look like dotted
identifiers. But you can't use that to refer to them, because that would
make it *very* awkward to do symbol lookup.
For example:
struct Foo { int bar; }
Foo test()
{
void bar() { }
writeln(&test.bar);
return Foo();
}
Should the `writeln` line invoke the `test` function, get the `bar` field
from its result, and take its address? Or should it take the address of
the nested function `bar`?
More information about the Digitalmars-d-learn
mailing list