MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Why HoldForm[] shows this expression in red in notebook?


On 2/19/2012 1:32 PM, Nasser M. Abbasi wrote:
> foo[x_, v_] := Module[{z = v},
>     {x^z, Hold[x^z], HoldForm[x^z]}
>     ];

Hi Nasser,

I assume it is a warning that z (the Module variable) will not be evaluated.

One might expect foo[x,2] to give {..., HoldForm[x^2]}.  It will not 
because z never evaluates to 2 (the expression that was substituted for v)

Why this warning is not shown for Hold?  I don't know.  I guess the 
results from HoldForm might be more confusing because if how it is 
printed.  I fell into this trap with HoldForm before (when trying to use 
it in plot labels) but not with Hold (where I typically focus on the 
hold-properties rather than formatting).

So again, this is just a guess.

-- 
Szabolcs Horvát
Visit Mathematica.SE:  http://mathematica.stackexchange.com/



  • Prev by Date: Re: multiple selection control
  • Next by Date: Re: Interrupt a block
  • Previous by thread: Why HoldForm[] shows this expression in red in notebook?
  • Next by thread: Re: Why HoldForm[] shows this expression in red in notebook?