Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Flat attribute and order of function definitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105115] Flat attribute and order of function definitions
  • From: Diego Fabregat <d.fabregat at gmail.com>
  • Date: Sat, 21 Nov 2009 03:35:18 -0500 (EST)

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

Global`f1

Attributes[f1]={Flat}

f1[expr_]:=expr



In[6]:= f1[c]

Out[6]= c

In[7]:= Clear[f1]

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

In[9]:= ?f1

Global`f1

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

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

In[12]:= ?f1

Global`f1

Attributes[f1]={Flat}

f1[expr_]:=expr



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