Thread overview | |||||
---|---|---|---|---|---|
|
July 28, 2015 Shouldn't __FUNCTION__ return function name? | ||||
---|---|---|---|---|
| ||||
Check this code: http://dpaste.dzfl.pl/a76db2cde13d When __FUNCTION__ is called inside a foreach body, it appears to be: f212.myFunction.__foreachbody1 Rather than: f212.myFunction. Is it correct? How can I get the function name? |
July 28, 2015 Re: Shouldn't __FUNCTION__ return function name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On 7/28/15 11:05 AM, Andrea Fontana wrote: > Check this code: > http://dpaste.dzfl.pl/a76db2cde13d > > When __FUNCTION__ is called inside a foreach body, it appears to be: > f212.myFunction.__foreachbody1 > > Rather than: > f212.myFunction. > > Is it correct? Yes. > How can I get the function name? Be outside foreach. The way foreach works in many cases (including foreach over an associative array), is that the compiler constructs an internal function delegate, then passes it to a handler. See opApply and how it works. It's the same for AAs. http://dlang.org/statement.html#ForeachStatement -Steve |
July 28, 2015 Re: Shouldn't __FUNCTION__ return function name? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 28 July 2015 at 15:13:28 UTC, Steven Schveighoffer wrote:
>> How can I get the function name?
>
> Be outside foreach. The way foreach works in many cases (including foreach over an associative array), is that the compiler constructs an internal function delegate, then passes it to a handler. See opApply and how it works. It's the same for AAs.
>
> http://dlang.org/statement.html#ForeachStatement
>
> -Steve
Too bad :|
|
Copyright © 1999-2021 by the D Language Foundation