Re: := vs = in some function definitions

*To*: mathgroup at smc.vnet.net*Subject*: [mg113411] Re: := vs = in some function definitions*From*: Albert Retey <awnl at gmx-topmail.de>*Date*: Wed, 27 Oct 2010 05:17:49 -0400 (EDT)*References*: <i9m7u7$j41$1@smc.vnet.net> <i9r80e$hp5$1@smc.vnet.net> <ia67b0$sqp$1@smc.vnet.net>

Hi, > Thanks for all the responses! Very insightful. > > Here's one more thing I can't figure out: > > testFunction[f_][x_, y_] = Module[{}, > Print[f[x, y]]; > 5 > ]; > testFunction[ArcTan][x, y] > > Why doesn't this function print out ArcTan[x, y]? it does, but since you used Set it does the Print when the definition is evaluated, not when the function call is evaluated. In the rule that is defined, Print isn't contained (in this case the rule is saved in SubValues, which is a rather dark area of Mathematica with not much documentation -- for many versions/years): In[7]:= SubValues[testFunction] Out[7]= {HoldPattern[testFunction[f_][x_, y_]] :> 5} What you probably wanted would be: testFunction[f_][x_, y_] := (Print[f[x, y]]; 5); which does Print when the function call is evaluated. (note that I omitted the Module with no variables, which doesn't do anything). Here is what the SubValues look like for that case: In[9]:= SubValues[testFunction] Out[9]= {HoldPattern[testFunction[f_][x_, y_]] :> (Print[f[x, y]]; 5)} hth, albert