I have a question. Is ClearAttributes the built-in functon work in current cell only? This is my code:
In first cell:
Set[a, 6]
In second cell:
ClearAttributes[Set, HoldFirst]
Attributes[Set]
Set[a, 7]
As you can see in the second cell there is no attribute HoldFirst of Set function.
However, if I make a call in the third cell:
Attributes[Set]
It turns out that the Set function has a HoldFirst attribute.
So does the ClearAttributes function only work in the cell in which it is called?
ClearAttributeshappens at the kernel level.Cellsare a front-end construct. If this doesn't make sense this will help. You're omitting the fact that yourSet[a, 7]causes a huge string of failures. ClearlySetresets itself, restoring itsHoldFirststate. – b3m2a1 Jan 07 '18 at 18:40Set. These functions have certain optimizations that insulate them from the full generality of the langage. This often means that any user-assigned attributes and definitions are either ignored or reset without warning. – Oleksandr R. Jan 07 '18 at 18:46