1

Some questions related to $Context and $ContextPath have already been asked and answered, but I still cannot fully grasp the concept. Evaluating

CompoundExpression[Begin["Ctx1`"], x = 1, End[], {Ctx1`x, x}]

in a pristine kernel yields {Ctx1`x, 1}. However, evaluating each level 1 statement in turn in a pristine kernel results in {1, x}. If this behaviour complies with the design, where is it documented?

  • 1
    It must be due to some quirk of the parsing like in this answer https://mathematica.stackexchange.com/a/598/72682 I'm surprised that printing out the contexts gives the correct printouts but still gets it wrong CompoundExpression[Print[$Context], Begin["Ctx1`"], Print[$Context], x = 1, End[], Print[$Context], {Ctx1`x, x}] – flinty Oct 03 '20 at 22:03
  • 1
    It behaves as expected, see also this answer with doc links: https://mathematica.stackexchange.com/a/119187/5478. @flinty Print and Begin are evaluated after the whole compound expression was parsed so there is no way for Begin to affect parsing of x. – Kuba Oct 04 '20 at 06:41
  • @Kuba Many thanks. It really is stated quite clearly in tutorial/ModularityAndTheNamingOfThings#5934 about "Setting Up Wolfram Language Packages". The question is resolved. – Florian Hamamelis Oct 04 '20 at 06:58

0 Answers0