I use JLink for connecting to the Mathematica kernel and evaluate some expressions. The In[] prompt is not continuous - it has step 3. I.e. the first expression is In[1] and after the evaluation the next one is In[4]. I obtained this kind of behavior on the rescent Mathematica 10.0.1 for Mac OS X 10.10. Is it a JLink bug?
1 Answer
$\begingroup$
$\endgroup$
I looked in the code of new JLink package of the Mathematica 10.0.1: it has 2 more evaluations under the hood per each evaluation and discards the answer from the Kernel. One is a preEval method that sets the evaluation format and another is postEval.
MathSessionTextPane.this.ml.evaluate("{JLink`Private`cfv, JLink`Private`sopts, JLink`Private`ddf} = {FormatValues[Continuation], Options[\"stdout\"], $DisplayFunction} ; Format[Continuation[_], OutputForm] = \"\" ; SetOptions[\"stdout\", FormatType -> OutputForm, CharacterEncoding -> \"Unicode\", PageWidth -> " + paneWidthInChars + "] ; " + "$DisplayFunction = " + df + ";");
MathSessionTextPane.this.ml.evaluate("FormatValues[Continuation] = JLink`Private`cfv ; SetOptions[\"stdout\", JLink`Private`sopts] ; $DisplayFunction = JLink`Private`ddf ;");
In
prompt should behave like when the Kernel is called via JLink. Can you explain why that is a problem? Assuming it is not recommended to rely on a specific ordering ofIn
statements when programmatically using the Kernel it would seem irrelevant what these are for a JLink program, wouldn't it? $\endgroup$