       Re: Question on Unevaluated

• To: mathgroup at smc.vnet.net
• Subject: [mg117287] Re: Question on Unevaluated
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Mon, 14 Mar 2011 05:58:30 -0500 (EST)

```
----- Original Message -----
> From: "Alexey" <lehin.p at gmail.com>
> To: mathgroup at smc.vnet.net
> Sent: Sunday, March 13, 2011 5:26:42 AM
> Subject: [mg117264] Question on Unevaluated
> Hello,
>
> I am puzzled a bit by the Documentation for Unevaluated. Under "More
>
> "f[Unevaluated[expr]] effectively works by temporarily setting
> attributes so that f holds its argument unevaluated, then evaluating
> f[expr].".
>
> After reading this I expect that
>
> f[Unevaluated[1 + 1]; 2 + 1]
>
> will be returned completely unevaluated as it is when I set HoldFirst
> attribute to f:
>
> In:= SetAttributes[f, HoldFirst]
> f[Unevaluated[1 + 1]; 2 + 1]
>
> Out= f[Unevaluated[1 + 1]; 2 + 1]
>
> But in really we get
>
> In:= f[Unevaluated[1 + 1]; 2 + 1]
>
> Out= f
>
> This leads me to a question: what is implied in documentation? Which
> attributes are temporarily set and to which function?

In your example the "funtion" in question would be CompoundExpression. So Mathematica is indeed acting as documented here.

By way of contrast, note the effect for the examples below.

In:= f[Unevaluated[1 + 1], 2 + 1]
Out= f[Unevaluated[1 + 1], 3]

In:= f[Unevaluated[1 + 1; 2 + 1]]
Out= f[Unevaluated[1 + 1; 2 + 1]]

You can have Mathematica show the structure simply by wrapping with FullForm[Hold[...]]

In:= Hold[f[Unevaluated[1 + 1]; 2 + 1]] // FullForm
Out//FullForm= FullForm[Hold[f[Unevaluated[1 + 1]; 2 + 1]]]

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: \$MaxNumber
• Next by Date: Re: Joining points of ListPlot
• Previous by thread: Re: Question on Unevaluated
• Next by thread: Re: Question on Unevaluated