0
$\begingroup$

I am trying to understand DownValues in regards to the evaluation of its output. Consider this:

In[1]:= f[x_] := 1 + 1;

In[2]:= DownValues[f]
Out[2]= {HoldPattern[f[x_]] :> 1 + 1} 

So far so good. Now lets change f so that it includes a graphic:

In[3]:= f[x_] := Graphics[Circle[]]
In[3]:= DownValues[f]

enter image description here

It works, but why the 1 + 1 remains unevaluated while the Graphics command is evaluated? This becomes a problem in a case like this:

In[4]:= f[r_] := Graphics[Circle[{0, 0}, r]]
In[4]:= DownValues[f]

enter image description here enter image description here

Is this the expected behavior? Is there a way to prevent the evaluation of the definitions returned by DownValues?

I am using Mathematica 10.1 / Win7

Motivation: I was exploring the idea of creating a code analysis function to help me create function calls graphs. For this, I need to be able to fetch the unevaluated definitions of all the functions defined in the Global` context.

$\endgroup$
  • $\begingroup$ This is a duplicate. Let me see if I can find it. Short answer: it's just an output formatting result, not standard evaluation. $\endgroup$ – Mr.Wizard May 12 '15 at 15:47
  • 3
    $\begingroup$ Found it; proposed duplicate: (32296); see also: (5617685) $\endgroup$ – Mr.Wizard May 12 '15 at 15:49
  • $\begingroup$ Thank you for pointing me towards the solution. $\endgroup$ – Gustavo Delfino May 13 '15 at 8:56