In the following the full context form of Test
is not required as "Aaa`"
is added to $ContextPath
Aaa`Test[x_] := x + 1;
context = "Aaa`";
PrependTo[$ContextPath, context];
Context@Test
(* "Aaa`" *)
The same however, doesn't seem to apply within scoping constructs.
Quit
Aaa`Test[x_] := x + 1;
With[{context = "Aaa`"},
PrependTo[$ContextPath, context];
Context@Test
]
(* "Global`" *)
Note that Quit
is needed as the expected behaviour happens if evaluated twice.
I find this surprising as it indicates an a priori parsing of the body within scoping constructs (the same applies if With
is replaced by Block
or Module
) whereas I would have anticipated that this would be changeable along with normal control-flow expectations. Is this a bug or a feature?