# Why does $Failed have attribute HoldAll? Why does $Failed have attribute HoldAll? Are there typical situations where $Failed is returned as a head that must not evaluate further, or is this just a relic from Mathematica's early times? In[1]:= Attributes[$Failed]
Out[1]= {HoldAll, Protected}

• It is not very common, but sometimes, $Failed is used as a head, like f[x___]:=$Failed[x]. This makes it possible to have "return code" returned, rather than just a fact of failure. Basically, when this is used, it is usually in the error-reporting fall-back rule. In some cases, one may want to not evaluate the arguments x (e.g. if f is Hold*). I don't use $Failed in such fashion myself, but I've seen such code, and I don't find any particular reason not to use it in this way. Of course, one could also use $Failed[Hold[x]], but arguably this is a clumsier method. Feb 19 '14 at 2:00
• @LeonidShifrin I think you should post that as an answer. I doubt we can get a more insightful one. Feb 19 '14 at 2:29
• @belisarius I'd wait for a while. There are much more knowledgable folks than me, who may shed some more light on this. There might be other reasons of which I am not aware. My previous comment has a status of an educated guess backed by some evidence, rather than an authoritative answer, which is why I posted it as a comment. Feb 19 '14 at 2:33
• @LeonidShifrin Ok,just bookmark it for later if nothing better comes in. We should keep out unanswered pyre low :) Feb 19 '14 at 2:35
• @LeonidShifrin Hehe, I remember that a lot of your posts end with "I will change/improve/revisit this soon":) That's why I agree with beli 100%. I would also recommend to post the comment as an answer. The hypothetical more knowledgable people can either post their own answer or improve your own. Feb 19 '14 at 9:56

It is not very common, but sometimes, $Failed is used as a head, like f[x___]:=$Failed[x]

Basically, when this is used, it is usually in the error-reporting fall-back rule. In some cases, one may want to not evaluate the arguments x (e.g. if f is Hold*). I don't use $Failed in such fashion myself, but I've seen such code, and I don't find any particular reason not to use it in this way. Of course, one could also use $Failed[Hold[x]], but arguably this is a clumsier method.