MathGroup Archive 2006

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

Search the Archive

Re: A test with options


>>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