MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Types in Mathematica

  • To: mathgroup at
  • Subject: [mg62281] Re: Types in Mathematica
  • From: "Steven T. Hatton" <hattons at>
  • Date: Sat, 19 Nov 2005 05:54:02 -0500 (EST)
  • References: <> <> <dl8s4g$n41$> <dl980q$r2a$> <> <dlc96b$m81$> <dlhibt$5ki$> <dlkc76$pq0$>
  • Sender: owner-wri-mathgroup at

John Doty wrote:

> Steven T. Hatton wrote:
>> Andrzej Kozlowski wrote:
>>>Is Table a "variable in the sense of computer science"?
>> It is an l-value.  And yes, in computer science a constant integer is a
>> "variable".  Furthermore, I can modify Table by unprotecting it, and
>> assigning to it.
> Hmm,
> In[1]:= a := 1 /; b == 0
> In[2]:= a := 0 /; b == 1
> In[3]:= a
> Out[3]= a
> In[4]:= b = 0
> Out[4]= 0
> In[5]:= a
> Out[5]= 1
> In[6]:= a := 42
> In[7]:= a
> Out[7]= 1
> In[8]:= b=.
> In[9]:= a
> Out[9]= 42
> Never seen an l-value behave like a :-)

I have. JavaScript. 

The way Mathematica is implemented -at least conceptually- is that every
symbol is interned in a symbol table.  Each symbol has a name which is a
string, as well as a property list.  The property list holds the
transformation rules assigned to the symbol.  The symbol also has a set of
attributes which are either set or unset. 

An expression is a contiguous array of pointers the 0th element of which is
called the head, and points to the entry in the symbol table associated
with it.  The remaining elements of the array point to the list of

> Mathematica doesn't have l-values. It has UpValues and DownValues, Set
> and SetDelayed, Pattern and Condition, etc. These things interact in
> marvelous ways uncontemplated in other languages.

These are merely values assigned to the symbol.  They are accessed in a
specific order of precedence during evaluation.  Up values are a means of
associating a rule with a symbol in such a way that it is used if the
symbol happens to appear in a specified context.

>  > Functions in Mathematica are not unlike functors in C++.
> Functional programming is not really built into the Mathematica
> *language* at all: it is a matter of convention. For example:
> In[10]:= x_[s] ^:= Sin[x]
> In[11]:= Pi[s]
> Out[11]= 0
> Try defining an "argument" that operates on its "function" in any other
> language.

I can pass a function object to another function object in C++.  The passed
functor (argument) can certainly modify the state of the object to which it
is passed.

The Mathematica Wiki:
Math for Comp Sci
Math for the WWW:

  • Prev by Date: Re: Performance Improvement - Need help
  • Next by Date: Re: java method in NDsolveDavid Bailey,
  • Previous by thread: Re: Types in Mathematica
  • Next by thread: Re: Types in Mathematica