Use context-stripped names in str(Expression)#1315
Conversation
|
|
||
| def get_head_name(self): | ||
| return self._head.name if isinstance(self._head, Symbol) else "" | ||
| def get_head_name(self, short=False) -> str: |
| def __str__(self) -> str: | ||
| return "%s[%s]" % ( | ||
| str(self.head), | ||
| self.get_head_name(short=True), |
There was a problem hiding this comment.
This could be a problem if there are symbols with the same name in different contexts, which is something that you would want to detect in debugging.
There was a problem hiding this comment.
repr still shows the long names.
Personally in my debugging, I don't recall needing this yet. And in WMA I am seeing short names used in errors and tracing.
We could add a user-defined setting, but this is more complicated.
There was a problem hiding this comment.
This is because WMA uses FullForm to show expressions "without formatting". For example,
In[1]:= F[s`p,t]//FullForm
Out[1]//FullForm= F[s`p, t]
There was a problem hiding this comment.
This is useful and related, but different.
This is a useful Mathics3 user function. But in addition, there is always the need for lower-level displays of elements. These functions get called and appear in error messages as well as in that TraceEvaluation.
What I've been noticing is that WMA does not fill out context paths when reporting error messages and we do. I can't find a good example of this but I am sure you've seen experienced these.
There was a problem hiding this comment.
Yep, because WMA uses "FullForm". We use just str() or repr()
There was a problem hiding this comment.
Ok - then this can wait until after we have boxing under control and get superseded.
|
Maybe #1316 could be useful. Instead of |
If you can find evidence of WMA doing something like this in its trace routines like |
|
Let`s see if this helps. This is what happends in WMA, if I interrupt the evaluation with Ctrl+C: In any case, it is not a great debugger either... |
|
Notice that in the example "Show" shows the FullForm of the current expression, and "Trace" shows the variables without the context. |
In neither case am I seeing Thanks for the information. I am sure in the future we will be able to provide this and much more. But now is probably not the time to add this. I was looking for small non-controversial user-facing issues. |

In the str(Expression), show
Headas a context-stripped name, e.g.Plusinstead ofSystem`Plus. We see these long names inTraceEvaluationand in error messages. With this change we now will see:instead of:
which is what I think is desired most of the time. In the rare occasions where one wants the full context path,
repr()shows that.Also, in the future I think we will have better debugging features that can fill out this information on demand.