Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

I'm strongly encouraging to read a very nice answer of Szabolcs:

How symbol lookup actually worksHow symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

I'm strongly encouraging to read a very nice answer of Szabolcs:

How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

I'm strongly encouraging to read a very nice answer of Szabolcs:

How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

added 18 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

You canI'm strongly encouraging to read more ina very nice answer of Szabolcs:   

How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

You can read more in very nice answer of Szabolcs:  How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

I'm strongly encouraging to read a very nice answer of Szabolcs: 

How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

added 51 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (inthat means in aPackage` since, because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in Private`aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

You can read more in very nice answer of Szabolcs: How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (in aPackage` since the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[].

You can read more in very nice answer of Szabolcs: How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

?aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


?aPackage`Private`aTestFunction 

enter image description here

Shortly:

Here what is going on, aTestFunction was created in aPackage` context, then you've removed it and since the current context is aPackage`Private` the definition of your function is created there.

More precisely:

New symbols are created in current $Context during read time, (1) the existance of aTestFunction between BeginPackage and Begin lines makes the aTestFunction an exported symbol (that means in aPackage` , because the symbol was not found and the current $Context is apackage` ).

After (2) Remove it's no longer there and (3) your definition is read in aPackage`Private` context. But aPackage`Private` is not going to be on $ContextPath or $Context after EndPackage[] so it is not found by ?.

You can read more in very nice answer of Szabolcs: How symbol lookup actually works

BeginPackage["aPackage`"]; aTestFunction::usage = "aTestFunction usage"; (*1*) Begin["`Private`"]; Remove[aTestFunction]; (*2*) aTestFunction[arg_] := arg + 1; (*3*) Protect[aTestFunction]; End[]; EndPackage; 

? aTestFunction 

Information::notfound: Symbol aTestFunction not found. >>


? aPackage`Private`aTestFunction 

enter image description here

added 164 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
added 18 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
deleted 19 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
added 190 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading