Re: What does FullForm[ ] actually do?
- To: mathgroup at smc.vnet.net
- Subject: [mg90507] Re: What does FullForm[ ] actually do?
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Fri, 11 Jul 2008 02:03:48 -0400 (EDT)
- References: <g54oj0$eu9$1@smc.vnet.net>
FullForm[] prints the expression using a notation that makes it easy for
us to see its structure.
In[1]:= Attributes[FullForm]
Out[1]= {Protected}
It does not have any Hold* attributes so yes, the expression is
evaluated before the FullForm is printed.
In[2]:= FullForm[Hold[a=b]]
Out[2]//FullForm= Hold[Set[a,b]]
In[3]:= FullForm[Hold[a=b;]]
Out[3]//FullForm= Hold[CompoundExpression[Set[a,b],Null]]
AES wrote:
> I'm having trouble grasping just what it is that FullForm[ ] does. For
> example:
>
> 1) Page 424 of the M5 Book says:
>
> "FullForm[expr] shows the internal form of an
> expression in explicit functional notation"
>
> and gives a moderately complex example of this.
>
> I don't find it clearly stated, however, there or anywhere else in the
> immediately accessible M5 or M6 documentation, whether executing
> "FullForm[expr]" also executes the "expr" itself, although some
> experimenting seems to show that it does. If so, perhaps the
> documentation ought to make this clear. . . ?
>
> 2) Then, just as an example, executing FullForm[y = {a+b}] gives (that
> is, Prints, or displays on screen) only the output List[a,b] -- the "y
> =" is gone.
>
> But isn't the full expr that's operated on by FullForm, or that forms
> the argument of FullForm[expr], the complete expression "y = {a+b}".
> That's what fits the stated syntax of the FullForm[expr] command -- and
> moreover, page 230 of the M5 Book says:
>
> 2.1.1 Everything Is an Expression
>
> "...everything you type into M is treated as an expression."
>
> Isn't the "y = " part typed in as part of expr also? Doesn't it have to
> have some form of "internal form"?
>
> 3) Even without the "y =" part, suppose we execute either of the inputs
> FullForm[y={a+b};] or FullForm[{a+b};] (with a semicolon added).
>
> Either of these gives us back the displayed result "Null" -- but the
> first of them also sets the value of y to {a+b}, confirming that the
> complete expression inside the FullForm brackets was indeed executed.
>
> But what is it that's "null" here? The "{a+b}" or even the "{a+b};"
> part clearly isn't null, since it gets put into y in the first form.
> And isn't ";" (the semicolon) also an expression, and also part of the
> "{a+b};" expression? ("Everything in M is an expression.") Don't both
> ; and {a+b}; have to have an internal form?
>
> The bottom line seems to be that FullForm[{a+b}], when executed, in some
> cases does as claimed "show the internal form of that expression in
> explicit functional notation."
>
> However, the FullForm[{a+b};] or FullForm[y={a+b};] examples seem to
> show that executing FullForm[expr] returns the result of executing that
> expr, not the expression itself . . . ?
>