explanation of the evaluation properties of 2nd args of Block With & Module via example
- To: mathgroup at smc.vnet.net
- Subject: [mg80587] explanation of the evaluation properties of 2nd args of Block With & Module via example
- From: "Chris Chiasson" <chris at chiasson.name>
- Date: Sun, 26 Aug 2007 04:29:22 -0400 (EDT)
As part of a replacement, the process of evaluation of the second
arguments of Block, With, and Module that have a head of Condition
(/;) may be explained by the analogous behavior of a (possibly
nested) expression containing RuleCondition and $ConditionHold:
In[1]:=
HoldComplete@a/.a:>Block[{b=4},b+1/;True]
HoldComplete@a/.a:>With[{b=4},b+1/;True]
HoldComplete@a/.a:>Module[{b=4},b+1/;True]
%//ReleaseHold(*the temporary value is still stored, and will take
effect if released*)
Out[1]= HoldComplete[5]
Out[2]= HoldComplete[4+1]
Out[3]= HoldComplete[b$66+1]
Out[4]= 5
In[5]:=
b=4;
HoldComplete@a/.a:>RuleCondition[b+1,True]
HoldComplete@a/.a:>RuleCondition[$ConditionHold[blah+1]/.blah->4,True]
HoldComplete@a/.a:>RuleCondition[$ConditionHold[b+1],True]
%//ReleaseHold(*the value is still stored, and will take effect if released*)
b=.;
Out[6]= HoldComplete[5]
Out[7]= HoldComplete[4+1]
Out[8]= HoldComplete[b+1]
Out[9]= 5
--
http://chris.chiasson.name/