-
-
Notifications
You must be signed in to change notification settings - Fork 60
using a private symbol to store the state inside DisplayForm. #617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: DisplayForm
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
from mathics.core.symbols import ( | ||
Atom, | ||
Symbol, | ||
SymbolTrue, | ||
) | ||
|
||
from mathics.core.systemsymbols import ( | ||
|
@@ -46,6 +47,12 @@ | |
) | ||
|
||
|
||
# Afterwards, we can find a better name | ||
SYMBOL_NO_FORMATBOXES = Symbol( | ||
"System`Private`MakeBoxes`PrivateSymbolThatControlsTheStateOfDisplayForm" | ||
) | ||
|
||
|
||
def int_to_s_exp(expr, n): | ||
n = expr.get_int_value() | ||
if n < 0: | ||
|
@@ -396,7 +403,7 @@ def apply_general(self, expr, f, evaluation): | |
if isinstance(expr, BoxElementMixin): | ||
# If we are inside a DisplayForm block, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really just DisplayForm that could do this? There are no other forms that are like this. Or this isn't something Form creator might want to do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By now, this is the only case. This could also be a way to implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What makes a print form "non-standard"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MakeBoxes accepts
Makeboxes first applies the format rules associated with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://reference.wolfram.com/language/ref/TraditionalForm.html says:
Does this provide a mechanism for how to do this? If so, possibly the same is could done for StandardForm (and is done but just not mentioned). Sometimes it happens that only in implementing the second thing of a kind the general mechanism, and the first is done in a more hacky way is not retrofitted. |
||
# BoxElementMixin are not processed. | ||
if evaluation.in_display_form: | ||
if SYMBOL_NO_FORMATBOXES.evaluate(evaluation) is SymbolTrue: | ||
return expr | ||
expr = expr.to_expression() | ||
if isinstance(expr, Atom): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small thing - please indent nested
<dt>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rocky, the question is, do you think that this is a better approach?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmatera good question. I have to think about it. What I'd be looking for is clues in the WMA code.
Think of this like the way a physicist would. We have two hypotheses for how this might have been coded in WMA. Is there a test that distinguishes these? Suppose we hypothesize that WMA follows the WMA way to do this, what test could we come up with that would distinguish the implementations? (Likewise for the other way to code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ja, it is a curious request! Because it is exactly as this physicist is trying to distinguish what is the implementation in WMA :)
Look at this, for example,
If I believe in this output, I have to assume that there is not a private hidden symbol but an internal variable inside the kernel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok - I trust your conclusion, but I don't follow it. The output above doesn't indicate anything to me one way or another. Please break it down for a novice.
If it were implemented as a private hidden symbol what then would you expect to see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably implement TracePrint so that we can check correspondence easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect an evaluation for the corresponding hidden symbol. This is an example in which internal variables are used:
(I just cut the first lines)
Notice the use of symbols in hidden contexts (BoxForm
ls, IntegrateDump
TestLimits, BoxFormopt). Tracing
MakeBoxes[DisplayForm[...]]` I do not see such kind of symbols in hidden contexts.