Re: Re: scope all wrong? in Mathematica 4.1
- To: mathgroup at smc.vnet.net
- Subject: [mg31900] Re: [mg31887] Re: scope all wrong? in Mathematica 4.1
- From: David Withoff <withoff at wolfram.com>
- Date: Mon, 10 Dec 2001 06:14:43 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
> Hello All. > The following notebook has been instrumented to reveal the origin of the > mysterious print statements for Fateman's third example. Looks like Allan > Hayes is right -- it seems that evaluation is being triggered in an attempt > to sort out possible effects of the previous rules on the one currently > being defined. Can WR confirm this and elaborate on just how SetDelayed > works? See my message of December 7. I'm afraid that some people are going to worry about it no matter what, but this is basically just an obscure bit of Mathematica trivia with no known practical consequences. It is not a fundamental part of the Mathematica programming language and has nothing to do with the topic at hand. These evaluations are part of the current strategy for ordering evaluation rules. This has nothing specifically to do with SetDelayed, except that SetDelayed is one of many functions that introduce evaluation rules. If anyone thinks they have a *practical* example where this might be an issue you could contact tech support, or just post it here (in a separate thread, please), which would undoubtedly provide hours of amusement for all concerned. > In[1]:= Module[{x}, > uu[x_?((Print["Initially, x is ", {x, Hold[x]}];x = 5; Print["x is ", x]; > True) &)] := x; > Print["in Module, x is " , x]] > > in Module, x is x$9 > > In[3]:= x$9 = 9 > > Out[3]= 9 > > In[4]:= Module[{x}, > uu[x_?((Print["Initially, x is ", {x, Hold[x]}];x = 5; Print["x is ", x]; > True) &)] := x; > Print["in Module, x is " , x]] > > Initially, x is {9,Hold[x$9]} > > x is 5 > > Initially, x is {x$20,Hold[x$20]} > > x is 5 > > in Module, x is 5 > > In[5]:= x$9 > > Out[5]= 5 etc. etc.