MathGroup Archive 2009

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

Search the Archive

Flat attribute and order of function definitions

Hi all,

Playing with some function definitions and attributes of functions I
got to a behaviour that I don't understand (example below). Depending
on the order I define function f1 and its attributes, it works or it
crashes. I know that the order of the definitions matters, so this is
kind of expected, but I would like to understand why this happens. Can
you point me to some reference that explains it?

Here you have the example:

In[1]:= Clear[f1]

In[2]:= ClearAttributes[f1, Flat]

In[3]:= f1[expr_] := expr

In[4]:= SetAttributes[f1, Flat]

In[5]:= ?f1




In[6]:= f1[c]

Out[6]= c

In[7]:= Clear[f1]

In[8]:= ClearAttributes[f1, Flat]

In[9]:= ?f1


In[10]:= SetAttributes[f1, Flat]

In[11]:= f1[expr_] := expr

In[12]:= ?f1




In[13]:= f1[c]

During evaluation of In[13]:= $IterationLimit::itlim: Iteration limit
of 4096 exceeded. >>

Out[13]= Hold[f1[c]]

  • Prev by Date: Re: Freeze Panes in Grid Expression
  • Next by Date: .NET/LINK USER GUIDE Comment: Calling static generic C# method
  • Previous by thread: Re: Batch save mode?
  • Next by thread: Re: Flat attribute and order of function definitions