MathGroup Archive 1998

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

Search the Archive

Re: Is this a bug?


In article <6p6oa9$56m at smc.vnet.net>,  <jfreeze at lexmark.com> wrote:
>
>The following seems to be a bug. In the first example, both the true and
>the false parts of If are being evaluated. In the secon example, only
>the true part. If this is not a bug, could someone please explain this
>behavior to me. Thanks
>
>In[1]:=
>     Clear[x,y];
>    
>If[True,Evaluate[ToExpression["x=5"]],Evaluate[ToExpression["y=5"]]];
>     Print[x,y];
>Out[1]:=
>     55

Quote: "Evaluate[expr] causes expr to be evaluated even if it appears as
the argument of a function whose attributes specify that it should be
held unevaluated."

When you ask for Attributes[If], Mathematica returns {HoldRest,
Protected}. Quote:  "HoldRest is an attribute which specifies that all
but the first argument to a function are to be maintained in an
unevaluated form."

So it's not a bug.

Mathematica's help browser is EXCELLENT.

--Ron Bruck




  • Prev by Date: Re: Is this a bug?
  • Next by Date: Re: $BatchOutput
  • Previous by thread: Re: Is this a bug?
  • Next by thread: Re: Re: Is this a bug?