RE: Re: Evaluation of args in pure functions

• To: mathgroup at smc.vnet.net
• Subject: [mg17128] RE: [mg17066] Re: [mg16924] Evaluation of args in pure functions
• From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
• Date: Sat, 17 Apr 1999 03:35:17 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Wolf Hartmut sent the post:
Subject: [mg17128] [mg17066] Re: [mg16924] Evaluation of args in pure functions

In that post he took a close look at certain aspects of the Mathematica evaluation
process.
-----------------------------

Tip:
Probably the most detailed description available on the evaluation process
is in Chapter 7 of the book "Power Programming with Mathematica the Kernel",
by David Wagner.  Although I don't David Wagner covers the nuances Wolf
discussed.

In addition David Wagner doesn't discuss a little detail on page 322 of the
big book from Wolfram.  Below I take the example from the big book a step
further.

In[1]:=
ClearAll[g,h];
g=h;
h[2]=5;
g[1+1]=4+6

Out[1]=
10

In[2]:=
?g
"Global`g"
g = h

Above we see there is no definition for g[2] or g[1+1].
----------------------------

In[3]:=
?h
"Global`h"
h[2] = 10

Above we see the earlier definition
for (h) was changed to h[2]=10.

----------------------------

You can evaluate (g[1+1]=4+6) inside TracePrint and see the order of how
things are evaluated.
It goes like this:

The right side evaluates as
4+6 --> 10

The head of the left side evaluates as
g --> h

The argument of the left side evaluates as
1+1 --> 2

We now have h[2] on the left side of Set (=).  The expression h[2] doesn't
evaluate any further and we have the expression ( h[2]=10 ).  The value (10)
is assigned to ( h[2] ), and an appropriate output cell is sent to the Front
End.

Regards,
Ted Ersek

```

• Prev by Date: Re: List of function-heads
• Next by Date: Re: List of function-heads
• Previous by thread: Re: Evaluation of args in pure functions
• Next by thread: overwrite separate notebook