Re: Re: will someone explain the behavior of Unevaluated in this example?
- To: mathgroup at smc.vnet.net
- Subject: [mg71452] Re: [mg71435] Re: will someone explain the behavior of Unevaluated in this example?
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sun, 19 Nov 2006 01:10:08 -0500 (EST)
- References: <acbec1a40611180027m5fb197b9hcb414978770ca4ef@mail.gmail.com> <200611180941.EAA16666@smc.vnet.net>
I don't think Unevaluated can be Blocked. For example, compare: Block[{x,Unevaluated=U},Unevaluated[x]] x with Block[{x, Hold = U, ReleaseHold}, ReleaseHold[Hold[x]]] U[x] The reason is that the Unevaluated is removed before the entire expression (with Head Block) is evaluated, so Block has completely no effect. You can see it even more clearly here: Block[{x, Unevaluated = U}, Unevaluated[Unevaluated[x]]] U[x] The outer Unevaluated was removed before Block was evaluated, then during evaluation of Block the inner Unevaluated was replaced with U. Andrzej Kozlowski On 18 Nov 2006, at 18:41, Chris Chiasson wrote: > this expression should, imho, produce an error or False > > Block[{names,Unevaluated},Unevaluated[names["1","0"]]===names > ["1","0"]] > > but it produces True > > On 11/18/06, Chris Chiasson <chris at chiasson.name> wrote: >> sorry, that second one should be: >> >> Block[{q = 5, f, g}, {Module[{f = >> Unevaluated[q], g}, g = >> Block[{Unevaluated}, First@f]; f === g], Unevaluated[q] === q}] >> >> (and it still produces {False, False}) >> >> also, I have a similar expression in some code, and a TracePrint >> on it >> contains this: >> >> Unevaluated[names["1", "0"]] === names["1", "0"] >> >> with the _next line_ saying False >> >> (even though Unevaluated and SameQ aren't Blocked and names isn't >> Blocked, but doesn't have a value) (afaik) >> >> On 11/18/06, Chris Chiasson <chris at chiasson.name> wrote: >>> Block[{q = 5, f, g}, {Module[{f = >>> Unevaluated[q], g}, g = Evaluate@f; f === g], Unevaluated[q] >>> === q}] >>> >>> gives {True,False}, which is unexpected (by myself) >>> >>> Block[{q = 5, f, g}, {Module[{f = Unevaluated[q], g}, >>> g = Block[{Unevaluated}, f]; f === g], Unevaluated[q] === q}] >>> >>> gives {False,False}, as expected >>> >>> -- >>> http://chris.chiasson.name/ >>> >> >> >> -- >> http://chris.chiasson.name/ >> > > > -- > http://chris.chiasson.name/ >
- References:
- Re: will someone explain the behavior of Unevaluated in this example?
- From: "Chris Chiasson" <chris@chiasson.name>
- Re: will someone explain the behavior of Unevaluated in this example?