[Date Index]
[Thread Index]
[Author Index]
Re: Evaluation question
*To*: mathgroup at smc.vnet.net
*Subject*: [mg82159] Re: [mg82106] Evaluation question
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Sat, 13 Oct 2007 03:59:07 -0400 (EDT)
*References*: <200710120656.CAA04613@smc.vnet.net>
On 12 Oct 2007, at 15:56, Yaroslav Bulatov wrote:
> At what point is "Unevaluated" stripped?
>
> For instance, in the following, unevaluated is stripped even though
> arguments are not evaluated
> a := Unevaluated[2 + 3]
>
> So a:=Unevaluated[2+3] and a=Unevaluated[2+3] seem to work the same
> here
>
Unevaluated is stripped from an argument of a function before the
function is checked for the Hold attributes. It is easy to see this
with Trace:
SetAttributes[f, HoldAll]
Trace[f[Unevaluated[x]]]
{HoldForm[f[x]], HoldForm[f[Unevaluated[x]]]}
Unevaluated was stripped but then it was restored, as the expression
did not change. On the other hand here Unevaluated is stripped but
this time not restred:
Trace[a := Unevaluated[2 + 3]]
{HoldForm[a := 2 + 3], HoldForm[Null]}
Normally, Unevaluated that had been stripped from an argument is
restored if no applicable rules were found after it was stripped. In
this case it is, however, not restored, and to tell the truth at the
moment it is not clear to me why.
> Also, consider
>
> a=Unevaluated[Unevaluated[2+3]]
> OwnValues[a]
>
> OwnValues doesn't show that a has an Unevaluated wrapper, even though
> a /. OwnValues[a] results in Unevaluated[2+3], why is that?
Doing a Trace on OwnValues clearly shows evaluation:
Attributes[OwnValues]
{HoldAll, Protected}
a = Unevaluated[Unevaluated[2 + 3]]
Trace[OwnValues[a]]
{HoldForm[OwnValues[a]], HoldForm[{HoldPattern[a] :> Unevaluated[2 +
3]}],
{HoldForm[HoldPattern[a] :> 2 + 3],
HoldForm[HoldPattern[a] :> 2 + 3]},
HoldForm[{HoldPattern[a] :> 2 + 3}]}
You can clealry see that Unevaluated got stripped during evaluation of:
HoldPattern[a] :> Unevaluated[2 + 3]
HoldPattern[a] :> 2 + 3
Just as in the earlier example Unevaluated is stripped but not
restored, and again I find it a bit of a puzzle. Perhaps someone else
can explain this point?
Andrzej Kozlowski
>
> Is there any place that documents at which point OwnValues comes into
> evaluation? For instance, setting a high level trap (Robby Villegas'
> technique) on Set/OwnValues/Replace/ReplaceAll shows no trace of
> OwnValues evaluation.
>
> Is OwnValue application equivalent to
> "symbol/.ReplaceAll[OwnValues[symbol]]"?
>
>
Prev by Date:
**Re: Non-numeric arguments to Compile-d functions**
Next by Date:
**Custom Control of Axes and Plot Labels in 2D and 3D Plots**
Previous by thread:
**Evaluation question**
Next by thread:
**Re: Evaluation question**
| |