New answers tagged

5

In addition to Rolf's workaround. This is expected and works the same in V9 and V10. NotebookEvaluate / Details & Options: By default, NotebookEvaluate evaluates the cells of a notebook in the same way that Get evaluates the lines of a package file. Messages, print output, and other side effects will be placed as output to the cell that called ...


7

If you look at the definition of NotebookEvaluate, by means of Needs["GeneralUtilities`"]; GeneralUtilities`PrintDefinitions[NotebookEvaluate] you see that the design is strange: always $ParentLink is set to First@$FrontEnd, and the designer obviously never thought about your use case. However, it is easy to achieve what you want, just define e.g. ...


1

Looks like this is a problem with the Suggestions Bar http://mathematica.stackexchange.com/a/75284/6804 When I disable it, I get the same context path consistently. This is version 10.2. The problem does not appear in 10.4, suggestions bar on or off...


2

Based on Kuba's idea, this may also work: RawBoxes@MakeBoxes[FullForm[p + q]] /. x_String :> Context[Evaluate@Symbol@x] <> Last@StringSplit[x, "`"] /; NameQ[x]


9

To not mess with $ContextPath you can Block it just for that evaluation. e.g. Block[{$ContextPath = {}}, ...]. But we don't want to do that for the evaluation, input for FullForm should be evaluated freely and only the result should be returned with full symbols' names. To achieve that you should know: $ContextPath and $Context affect the typesetting. ...


0

I think the following also fits the present discussion. Who shadows whom? When you run (*cleanup*) $Context = "Global`"; Quiet@Remove["temp`*", "Global`*"]; (*--*) Global`x = "global"; BeginPackage["temp`"]; temp`x = "temp"; The last line generates the message ...::shdw: Symbol x appears in multiple contexts {temp`,Global`}; definitions in context temp`...


1

Consider using strings: BeginPackage["foo`"]; Unprotect @@ Names["foo`*"]; ClearAll @@ Names["foo`*"]; f::usage = "sol=f[x,plist]"; Begin["`Private`"]; f[x_, plist_] := With[{y = Lookup[plist, "y"], z = Lookup[plist, "z"]}, x + y + z]; End[]; Protect @@ Names["foo`*"]; EndPackage[]; paramList = {"y" -> 1, "z" -> 2}; sol = foo`f[x, paramList] Or ...


0

I think every line or statement that you enter into the frontend is parsed separately, so, when you use a CompoundStatement there is only one parsing process, while there is one for each line when you split them. From tutorial/Contexts we learn that unknown symbols are created in the $Context when they are not found in $ContextPath. Most likely the lookup ...



Top 50 recent answers are included