Re: Why HoldForm[] shows this expression in red in notebook?
- To: mathgroup at smc.vnet.net
- Subject: [mg125064] Re: Why HoldForm[] shows this expression in red in notebook?
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Mon, 20 Feb 2012 02:48:28 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jhqml4$f9t$1@smc.vnet.net>
On 19/02/2012 11:32, Nasser M. Abbasi wrote:
> foo[x_, v_] := Module[{z = v},
> {x^z, Hold[x^z], HoldForm[x^z]}
> ];
>
> Any one knows why the notebook shows the 'z' in the last term above in
> the red and but not the other z's?
>
> I am using V 8.04 on windows
>
> thanks
> --Nasser
>
>
I think the last z is coloured red because you are returning an
expression involving a local variable:
In[2]:= foo[a,b]
Out[2]= {a^b,Hold[a^z$6385],a^z$6385}
Notice the strange variable z$6385 - which is local. I can't see why the
middle term isn't red as well, but the left term evaluates to something
that doesn't involve a local variable.
Perhaps you really wanted to write this:
foo[x_, v_] := Module[{z = v},
{x^z, Hold[Evaluate[x^z]], HoldForm[Evaluate[x^z]]}
];
In[4]:= foo[a,b]
Out[4]= {a^b,Hold[a^b],a^b}
David Bailey
http://www.dbaileyconsultancy.co.uk