Re: Bug in Default[] or Bug in My Understanding?

*To*: mathgroup at smc.vnet.net*Subject*: [mg89312] Re: Bug in Default[] or Bug in My Understanding?*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Thu, 5 Jun 2008 00:43:34 -0400 (EDT)*Organization*: The Open University, Milton Keynes, UK*References*: <g1m8ea$i2$1@smc.vnet.net>

Salvatore Mangano wrote: > In[208]:= ClearAll[f] ; > Default[f,2] = 0; > > In[210]:= f[a_, b_.] := a + b > > In[211]:= f[1] > Out[211]= 1 > > In[212]:= (* Now change Default *) > Default[f,2] = 1; > > (* Note that Mathematica seems to recognize change *) > In[213]:= ?f > Global`f > f[a_,b_.]:=a+b > > f/:Default[f,2]=1 > > > (* But not really! Expected 2 *) > In[214]:= f[1] > Out[214]= 1 > > Even if it is a rule that you can't change the Default after the function is defined it is certainly not nice of Mathematica to allow such a change and advertise the change in the output of Definition[] and Information[]. > > I am using 6.0.2.0 on Windows XP. No bug here. The "more information" section of the online help for *Default[]* reads "The necessary values for Default[f] must always be defined before _. is used as an argument of f." The following works as expected: In[25]:= ClearAll[f]; Default[f, 2] = 0; f[a_, b_.] := a + b f[1] ClearAll[f]; Default[f, 2] = 1; f[a_, b_.] := a + b f[1] Out[28]= 1 Out[32]= 2 Regards, -- Jean-Marc