Re: Flat attribute and order of function definitions
- To: mathgroup at smc.vnet.net
- Subject: [mg105189] Re: Flat attribute and order of function definitions
- From: Diego Fabregat <d.fabregat at gmail.com>
- Date: Tue, 24 Nov 2009 05:46:19 -0500 (EST)
- References: <200911210835.DAA26477@smc.vnet.net> <heb67p$a9g$1@smc.vnet.net>
Thanks Leonid. Should I report this behaviour somehow? Will some developer see this post and decide whether it is a bug or not? By the way, just in case this is needed, I'm using Mathematica 6.0.0 on Mac Os X x86 (32-bit). Regards, Diego On Nov 22, 12:10 pm, Leonid Shifrin <lsh... at gmail.com> wrote: > Hi Diego, > > This looks like a bug to me. I experimented a bit - in the second case th= e > behavior persists even after the Flat attribute has been removed, and the > remaining definition for f1 looks innocent - should just return the value= as > in the first case. > > Regards, > Leonid > > On Sat, Nov 21, 2009 at 12:35 AM, Diego Fabregat <d.fabre... at gmail.com>wr= ote: > > > > > 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]]
- References:
- Flat attribute and order of function definitions
- From: Diego Fabregat <d.fabregat@gmail.com>
- Flat attribute and order of function definitions