[Issue 5140] Add __FUNCTION__

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 27 00:05:45 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5140


Rob T <alanb at ucora.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alanb at ucora.com


--- Comment #3 from Rob T <alanb at ucora.com> 2012-09-27 00:06:22 PDT ---
I'd like to add that __FUNCTION__ should operate in a consistent manner to
__LINE__ and __FILE__ such that when used as a default value for a function
parameter, the value is set where the function is called, not where the
function is defined.

void Log( string funcname = __FUNCTION__)
{
  writeln( funcname );
}


void func1()
{
  Log(); // displays "func1"
}

void main()
{
  Log(); // displays "main"
}

To be more useful, the nested function names will have to prefixed with parent
level function names, and probably also module name as the highest level.

void main()
{
  void func2()
  {
    Log(); // displays "main.func2"
  }
}

Member functions of class and struc should be prefixed with the class and struc
names respectively.

For templates and overloaded functions, including the function signature would
help resolve which version of a function was called. It may be best to have a
separate version of __FUNCTION__ that displays the function signature, for
example, C++ has __PRETTY_FUNCTION__ which includes the function signature.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list