# Tag Info

11

So how does MyFunction know the value of abc at the delayed function call (when it is called) if the Private context isn't on the $ContextPath There is a misunderstanding here. You are assuming that abc is searched for in some context only when MyFunction[something] is evaluated. This is not the case.$Context and $ContextPath only affect how source ... 7 The idea If you adhere to the convention that the size argument is always first in all your functions, then what you ask for can be achieved with some metaprogramming / dynamic environments. A dynamic environment is a function that takes your code, and generally modifies some definitions locally, only for the code that runs inside it. Preparation As a ... 7 Begin["Private"]; sets the current$Context to "CustomPackage Private". This causes two things: The symbol abc will be searched in the current context first, thus in"CustomPackagePrivate". Only if it is not found there, the search goes on along $ContextPath. If no matching symbol is found this way, a new symbol abc is created, namely in the current$...

6

All symbols are created at load time, so when you do: BeginPackage["X"]; x::usage="Declaring x as an exported symbol in the X context"; Begin["SomePrivateContext"]; x[a_]:=b End[]; EndPackage[]; x was created as Xx but the DownValues of x reference XSomePrivateContexta and XSomePrivateContextb which were created at the time the function was ...

6

There are several issues. First of all Context[] is the same here and can be replaced with $Context to make the example clearer. Now: DumpSave is HoldRest so in case of symbol = 2 it can save that definition instead of seeing 2. DumpSave["file", symbol] will save defnitions of symbol. So will DumpSave["file",$Context]. It will save information that $... 4 Notice that DumpSave has attribute HoldRest which prevents evaluation of all but its first argument. The documentation of Evaluate states: You can use Evaluate to override HoldFirst etc. attributes of built-in functions. Evaluate only overrides HoldFirst etc. attributes when it appears directly as the head of the function argument that would ... 3 Is there a practical way to use Operators Without Built-In Meanings in parallel calculations? The simpler workaround is to create the definition directly on the parallel kernels. CenterDot = Times ParallelEvaluate[CenterDot = Times] This must be done every time after a new subkernel is started. A better solution is to put the definitions in a package and ... 3 Another idea is to add tagging rules to a section cell, and define size so that it references that tagging rule. For instance: size := Replace[ PreviousCell[CellStyle -> "Section"], { cell_CellObject :> CurrentValue[cell, {TaggingRules, "MatrixSize"}, 5], _ -> 5 } ] The above code will look for the previous "Section" cell, and ... 3 I'd say the best solution is to re-design the function as testIntegrator[v_, x_, t_]:= … But if you insist on the original design, which is undoubtedly a bad design, then place a line x;t; before Begin["Private"] i.e. … x; t; Begin["Private"] … Don't forget to restart the kernel or Remove[Globalx, Globalt] first. BTW, if you just don't care about ... 3 So how does MyFunction know the value of abc at the delayed function call (when it is called) if the Private context isn't on the$ContextPath? because "CustomPackagePrivate" is the value of $Context when MyFunction is defined (i.e. it is not just$ContextPath that determines what a function sees but also what is on $Context). TL:DR This ... 3 A CW answer for clarity As of$CloudVersion 1.53.0.1 the CellContext is not supported in cloud notebooks. Yes, CellContext is not implemented in its entirety in the cloud yet, but it's on our list. – Jan Pöschko

3

You could try implementing one of these options -- whatever works best for you: SetOptions[EvaluationNotebook[], CellContext -> CellGroup] SetOptions[EvaluationNotebook[], CellContext -> Cell] other possibilities, less likely based on your requirements: SetOptions[EvaluationNotebook[], CellContext -> Notebook] SetOptions[EvaluationNotebook[], ...

2

I wasn't able to find how to use CellContext and cell groups in the Wolfram Cloud Notebook. As a workaround, I create a new context for each exercise using Begin and End: Ex 3.4 Begin["Ex3x4"] <<< mix of text cells and computation here >>> While[\$Context != "Global`", End[]] I wrap the End[] call in a While loop to ensure I restore ...

Only top voted, non community-wiki answers of a minimum length are eligible