3 added 18 characters in body edited Nov 15 '12 at 11:33 J. M. is away♦ 100k1010 gold badges317317 silver badges474474 bronze badges ItsIt's because avar is in TestHead Privatethe TestHeadPrivate context. One fix is to write your package with an explicit context on avar, such as Global.Global: TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Globalavar]] You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False: Trace@TestHead[a] (* {TestHead[a],TrueQ[{a}==Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex] ===TestHeadPrivateavar]], {{Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex]=== TestHeadPrivateavar],{{Head[a],avar},avar===TestHeadPrivateavar,False},{}}, {a}=={},False},TrueQ[False],False} *) Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global. TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Globalavar]] You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False: Trace@TestHead[a] (* {TestHead[a],TrueQ[{a}==Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex] ===TestHeadPrivateavar]], {{Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex]=== TestHeadPrivateavar],{{Head[a],avar},avar===TestHeadPrivateavar,False},{}}, {a}=={},False},TrueQ[False],False} *) It's because avar is in the TestHeadPrivate context. One fix is to write your package with an explicit context on avar, such as Global: TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Globalavar]] You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False: Trace@TestHead[a] (* {TestHead[a],TrueQ[{a}==Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex] ===TestHeadPrivateavar]], {{Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex]=== TestHeadPrivateavar],{{Head[a],avar},avar===TestHeadPrivateavar,False},{}}, {a}=={},False},TrueQ[False],False} *) 2 added 488 characters in body edited Nov 14 '12 at 21:52 halirutan♦ 97.9k66 gold badges230230 silver badges426426 bronze badges Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global. TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global$$$$avar]];Head[x]===Globalavar]] You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False: Trace@TestHead[a] (* {TestHead[a],TrueQ[{a}==Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex] ===TestHeadPrivateavar]], {{Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex]=== TestHeadPrivateavar],{{Head[a],avar},avar===TestHeadPrivateavar,False},{}}, {a}=={},False},TrueQ[False],False} *) Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global. TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global$$$$avar]] Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global. TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Globalavar]] You could have debugged this for instance with Trace and you would have seen instantly, why your SameQ results in False: Trace@TestHead[a] (* {TestHead[a],TrueQ[{a}==Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex] ===TestHeadPrivateavar]], {{Cases[{a},TestHeadPrivatex_/;Head[TestHeadPrivatex]=== TestHeadPrivateavar],{{Head[a],avar},avar===TestHeadPrivateavar,False},{}}, {a}=={},False},TrueQ[False],False} *) 1 answered Nov 14 '12 at 21:48 Andy Ross 17.4k22 gold badges5252 silver badges8787 bronze badges Its because avar is in TestHead Private context. One fix is to write your package with an explicit context on avar such as Global. TestHead[z___] := TrueQ[{z}==Cases[{z},x_/;Head[x]===Global$$$$avar]]