The Attributes
function itself has the attributes:
Attributes[Attributes]
{HoldAll,Listable,Protected}
In particular, it is Protected
which prevents me from redefining it:
Attributes = Foo
During evaluation of In[2]:= Set::wrsym: Symbol Attributes is Protected. >> Foo
however, I am able to modify Attributes
if I associate to a symbol:
Attributes[Foo] = {Protected}
{Protected}
which seems strange to me, because other functions which are Protected
can't do this. For example, with this newly protected Foo
function, the following fails:
Foo[a] = 5
During evaluation of In[5]:= Set::write: Tag Foo in Foo(a) is Protected. >> 5
So how does the Protected
attribute really work, and what makes the situation with the Attributes
function different from my simple Foo
function? Is it possible to have Foo
work in the same way as Attributes
?