I don't know that "canonical" really comes into it...This is all true, but then what is the right answer in the context of the original question. See, for example, the results of the following lines:You can get the arguments and the body of the function, but not the name.My suggestion would be to construct a named list of functions, where the name could be printed:Nice observation by @nfultz, so the answer to this thread's question would be :-All the other answers would simply return the parameter name itself ('f' in the example above) - I tried them all since I've been working on a function and experienced this issue of not being able to retrieve a function's name inside another function wherein the first is passed as parameter to the second function while calling it.

// Function name to invoke var fnName = "helloWorld"; // Params to pass to the function var params = "ctrlq.org" // Call function using Window object window [fnName] (params); This can be useful for invoking Google Apps Script functions as well. Type This function will return the caller’s function name.It is like Albert Vonpupp’s answer with a friendly wrapper.sys._getframe() is not guaranteed to be available in all implementations of Python (A call to stack[-1] will return the current process details.so now all you have to do with your function is decorate it and voila Questions: I have the following 2D distribution of points. Which function is "canonical" and should be printed?In a functional language, the name of the function is not really important. Don't fear the "OO", this would be a nice simple example to start using it. A standard soundex string is four characters long, but the SOUNDEX() function returns an arbitrarily long string. Say I have a bunch of functions, each with something likeSo are there any nice ways of getting the name of a predefined function as a string?Another approach would be to pass the names of the functions into your report function, and then get the functions themselves with the Then you have the names in your original character vector, and the functions have new names as you defined them. This is because we attempted to reference our array using rounded brackets. All international alphabetic characters outside the A …

Questions: During a presentation yesterday I had a colleague run one of my scripts on a fresh installation of Python 3.8.1. I’m sorry I don’t know php … The fix … site design / logo © 2020 Stack Exchange Inc; user contributions licensed under I was just hoping for something that'd do it for me. The nice-to-have would be not having to pass in a labels vector with the names I want, but that's certainly another option. The first of these constants is __func__, which is part of the C99 standard: . VB6 introduced the CallByName function which allows you to call a function or subroutine using the subroutine or function name stored as a string value. A Function object's read-only name property indicates the function's name as specified when it was created, or it may be rather anonymous or ''(an empty string) for functions created anonymously. Freejoy May 21, 2017, 8:56pm #6. All non-alphabetic characters in str are ignored. The source for this interactive example is stored in a GitHub repository. Stack Overflow works best with JavaScript enabled 6.50 Function Names as Strings. If not, any idea how to write Also the double underscores indicate to the reader this is a special attribute. This means that the only way is to save When a function is passed around as an object, it loses its name. objectName = as.character(quote(object)) works as wellWas not really the authors question and is a not so nice workaround. By clicking “Post Your Answer”, you agree to our To subscribe to this RSS feed, copy and paste this URL into your RSS reader. As a bonus, classes and modules have a There are also other fun properties of functions. In this case, the Or, if you really want to keep the original function names, just assign them locally with the assign function:If you run this command right now, you will end up with the You can get the unevaluated arguments of a function via Just want to provide an example to show the advantage and limitation in this issue:I want to "save" a function with its name, as an option that would be used in another function:When I use it in foreach, I just need the function name, while actually, the original name can't be maintained, so you have no way to convert I unfortunately need to deparse the foreach code so want the original name shown in the string. By using our site, you acknowledge that you have read and understand our The match.call function just gives you the name of the variable that held the function when it was being called, so in that sense, it's doing the only thing it can do. Hope my answer helps to all those who might be stuck for the same!Thanks for contributing an answer to Stack Overflow!

In a functional language, the name of the function is not really important. Answers: my_function.__name__ Using __name__ is the … You can easily rename functions, or have functions without names. This is where PHP says that a function name must be string when the variable is a boolean.