MathGroup Archive 2009

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

Search the Archive

Re: Flat attribute and order of function definitions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105141] Re: [mg105115] Flat attribute and order of function definitions
  • From: Leonid Shifrin <lshifr at gmail.com>
  • Date: Sun, 22 Nov 2009 06:09:38 -0500 (EST)
  • References: <200911210835.DAA26477@smc.vnet.net>

Hi Diego,

This looks like a bug to me. I experimented a bit - in the second case the
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.fabregat at gmail.com>wrote:

> 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: Batch save mode?
  • Next by Date: Re: Freeze Panes in Grid Expression (addendum)
  • Previous by thread: Flat attribute and order of function definitions
  • Next by thread: Re: Flat attribute and order of function definitions