MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: A test with options

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65471] Re: A test with options
  • From: Chris Rodgers <rodgers at physchem.NOSPAMox.aREMOVEc.uk>
  • Date: Mon, 3 Apr 2006 06:59:41 -0400 (EDT)
  • Organization: Oxford University, England
  • References: <200603311109.GAA15023@smc.vnet.net> <e0lldf$779$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

>>Below I create a test with an option and a function dependant upon the
>>test. As I see it the function fails to operate as I anticipated. So I
>>am missing something and need help understanding. 
>>
>>In[1]:=
>>ClearAll[TestQ]; 
>>Options[TestQ] = {EvaluationRequired -> False}; 
>>TestQ[a_] := EvaluationRequired /. Options[TestQ]; 
>>In[11]:=
>>b = a1
>>
>>Out[11]=
>>f[1]
>>
>>(* Now I am lost. Why in a new evaluation did the function input not get
>>retested and pass the test? *)
>>
> 
> 
> You need to use Update:
> 
> In[10]:=
> Update[f]
> b=a1
> 
> Out[11]=
> {100}

I have been bitten by this behaviour myself. As far as I could make out, 
the only way to ensure consistent evaluation in Mathematica is to run 
Update[] before every input - otherwise there's no guarantee of 
accuracy. It seems odd to me that Mathematica doesn't add e.g. variables 
mentioned in /; conditions to its list of dependencies when building the 
cache of previously evaluated results.

All the same, I realise that there may be good internal reasons for such 
behaviour. For interest, can you explain briefly why Mathematica is 
designed to ignore variables in e.g. /; conditions when building its 
internal evaluation cache?

Chris.


  • Prev by Date: Re: SpeakTextPacket in 5.2
  • Next by Date: Re: Strange Det function behavior.
  • Previous by thread: Re: A test with options
  • Next by thread: Technical question from new userr