WolframResearch / WolframLanguageForJupyter

Wolfram Language kernel for Jupyter notebooks
MIT License
1.05k stars 126 forks source link

Trace does not work #19

Closed szhorvat closed 4 years ago

szhorvat commented 5 years ago

Trace does not seem to work. It always returns {}.

image

Code:

f[x_]:=x^2; Trace[f[3+4]]

I thought that this happens because we are always in some evaluation (this can e.g. be detected with Stack[], which is not empty at the "top level"), but it's not clear why that would break Trace ...

On[] and Off[] also do not work, for tracing purposes.

image

Compare the command line:

In[1]:= f[x_]:=x^2; Trace[f[3+4]]                                               

                            2
Out[1]= {{3 + 4, 7}, f[7], 7 , 49}

In[2]:= On[]                                                                    

On::trace: On[] --> Null.

In[3]:= 3+4                                                                     

Plus::trace: 3 + 4 --> 7.

Out[3]= 7

In[4]:= Off[]                                                                   

In[5]:=         
cc-wr commented 5 years ago

The WolframLanguageForJupyter kernel is started by WolframKernel with the -script option.

This problem is inherent to that environment.

cc-wr commented 5 years ago

You should run into similar constraints with invocations like ./WolframKernel -run "Print[Trace[x=2+2]]".

cc-wr commented 5 years ago

It may be a good idea to try to launch the kernel script from wolframscript and -file, if they are available, since doing so will not cause this limitation.

cc-wr commented 4 years ago

There is an internal bug report for this limitation of the -script WolframKernel environment, and hopefully it will be fixed soon.

For now, I will close this issue: I will update it with any new information that appears.