MathGroup Archive 1998

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

Search the Archive

Re: Is this a bug?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13462] Re: Is this a bug?
  • From: bruck at math.usc.edu (Ronald Bruck)
  • Date: Fri, 24 Jul 1998 01:45:47 -0400
  • Organization: University of Southern California, Los Angeles, CA
  • References: <6p6oa9$56m@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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?