Subject: [mg124414] Re: Can the code of a function obtain the names of its arguments?

From: Michael Stern <nycstern at gmail.com>

Date: Thu, 19 Jan 2012 05:07:52 -0500 (EST)

Delivered-to: l-mathgroup@mail-archive0.wolfram.com

I asked a related question five years ago. You can find the discussion
at http://forums.wolfram.com/mathgroup/archive/2006/Aug/msg00111.html
and linked pages.
Personally, if I wanted do something like this today, I would probably
change the inputs of the function so that the user passes both the
variable and a string.
So, if
a=2;b=3;c=4.
then Max[{a,b,c}] == 4
but if we want the variable name, we can do something like this:
myMax[valueAndName_List]:=First[SortBy[valueAndName, First]][[2]]
myMax[{2," a"}, {3, "b"}, {4," c"}]
="c"
On 1/18/2012 5:59 AM, James Stein wrote:
> I fear the answer is no, because I suspect that once values are bound to
> the names, there might seem to be scant use in keeping the names around.
>
> But I have a little debugging routine in mind I'd like to implement, so I'm
> hoping the answer is yes. (And if yes, how?)