Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7993

Re: Can the code of a function obtain the names of its arguments?

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Can the code of a function obtain the names of its arguments?
Date 2012-01-19 10:09 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jf8q3v$3gu$1@smc.vnet.net> (permalink)
References <201201181059.FAA16568@smc.vnet.net>

Show all headers | View raw


Use the attribute HoldAll

SetAttributes[f,HoldAll];

f[x_,y_,z_]:=Module[
    {arg={HoldForm[x],HoldForm[y],HoldForm[z]}},
    Thread[arg->{x,y,z}]];

a=1;b=2;c=3;

f[a,b,c]

{a->1,b->2,c->3}


Bob Hanlon

On Wed, Jan 18, 2012 at 5:59 AM, James Stein <mathgroup@stein.org> 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?)



-- 
Bob Hanlon

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Can the code of a function obtain the names of its arguments? Bob Hanlon <hanlonr357@gmail.com> - 2012-01-19 10:09 +0000

csiph-web