digitalmars.D.learn - Get name of current function
- Mike B Johnson (7/7) Apr 23 2017 I'd like to get the symbolic name of the current function I'm in
- Mike Wey (6/15) Apr 23 2017 The __FUNCTION__ keyword would give you the fully qualified name of the
- cym13 (3/10) Apr 23 2017 So something like __FUNCTION__ or __PRETTY_FUNCTION__ ?
- Stanislav Blinov (4/11) Apr 23 2017 __FUNCTION__ and __PRETTY_FUNCTION__
I'd like to get the symbolic name of the current function I'm in
void foo()
{
writeln(thisFunc.stringof()); // prints foo
}
I need something short, elegant and doesn't require modifying
preexisting code... I'm sure D has something along those lines?
Apr 23 2017
On 04/23/2017 10:34 PM, Mike B Johnson wrote:
I'd like to get the symbolic name of the current function I'm in
void foo()
{
writeln(thisFunc.stringof()); // prints foo
}
I need something short, elegant and doesn't require modifying
preexisting code... I'm sure D has something along those lines?
The __FUNCTION__ keyword would give you the fully qualified name of the
function.
http://dlang.org/spec/traits.html#specialkeywords
--
Mike Wey
Apr 23 2017
On Sunday, 23 April 2017 at 20:34:12 UTC, Mike B Johnson wrote:
I'd like to get the symbolic name of the current function I'm in
void foo()
{
writeln(thisFunc.stringof()); // prints foo
}
I need something short, elegant and doesn't require modifying
preexisting code... I'm sure D has something along those lines?
So something like __FUNCTION__ or __PRETTY_FUNCTION__ ?
https://dlang.org/spec/traits.html#specialkeywords
Apr 23 2017
On Sunday, 23 April 2017 at 20:34:12 UTC, Mike B Johnson wrote:
I'd like to get the symbolic name of the current function I'm in
void foo()
{
writeln(thisFunc.stringof()); // prints foo
}
I need something short, elegant and doesn't require modifying
preexisting code... I'm sure D has something along those lines?
__FUNCTION__ and __PRETTY_FUNCTION__
both will give qualified name though (e.g. module.foo), so, if
necessary, that has to be stripped out manually.
Apr 23 2017









Mike Wey <mike-wey example.com> 