Skip to content

Comments

Makeboxes overhaul#1140

Merged
rocky merged 63 commits intomasterfrom
makeboxesoverhault
Mar 6, 2021
Merged

Makeboxes overhaul#1140
rocky merged 63 commits intomasterfrom
makeboxesoverhault

Conversation

@mmatera
Copy link
Contributor

@mmatera mmatera commented Jan 30, 2021

In this PR, I propose some changes in the way that the underlining MakeBoxes mechanism works. In Mathics 1.1 (and the current master branch) there are BoxConstruct classes, hard-linked to the interpreter, that defines how (the FullForm of ) an expression is translated to a set of rules to build the output, that can be processed by the front-end.
In WMA, the interpreter is designed in a way that MakeBoxes can be redefined to adapt the output to different front-ends.
With the proposed changes, the behavior of MakeBoxes in Mathics would be closer to the WMA, as described in Wolfram Reference: Textual Input and Output
This would allow for example, to overload the MakeBoxes for different classes of expressions (Graphics, Strings, etc) by the Pymathics mechanism, in a way that different front-ends build and render boxes in the most suitable way, according to the capabilities of the interface.

This will help also to make a transparent interface for the Matplotlib pymathics package.

@mmatera
Copy link
Contributor Author

mmatera commented Feb 21, 2021

Overall I really like this. Thanks so much for doing it.
Your welcome!
The main question I have is, how can I see the new wonderful behavior? Would you describe something please?
At this point, the idea is that you cannot see it from mathics-core: everything should work as before. To see the differences, you would need to see in the code, or trying to write a pymathics module that uses this new behaviour.

Is there any test I can run to see the difference?
In principle, if you load (my version of) pymathics-matplotlib, you would see the difference (in one case it works, otherwise no).

@rocky
Copy link
Member

rocky commented Feb 21, 2021

Should we be able to write a test that alters Makebox[] in a valid way and see the change in behavior there?

@mmatera
Copy link
Contributor Author

mmatera commented Mar 4, 2021

Overall I really like this. Thanks so much for doing it.

The main question I have is, how can I see the new wonderful behavior? Would you describe something please?

Is there any test I can run to see the difference?
I added some basic tests in te

Overall I really like this. Thanks so much for doing it.

The main question I have is, how can I see the new wonderful behavior? Would you describe something please?

Is there any test I can run to see the difference?

@rocky, please look at test/test_custom_boxconstruct.py to see some very basic tests.

If there are no extra thoughts, observations, or complaints, I would like to merge this during the weekend to finish implementing the pymathics-matplotlib and pymathics-asy.



class InstancableBuiltin(Builtin):
class InstanceableBuiltin(Builtin):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name feels a bit weird to me. In a PR off of this I might have changed the name. I don't remember. Right now I can't come up with another name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I can't come up with another name and it problably isn't that important either.

Sorry for the delay - thanks for your patience.

@rocky
Copy link
Member

rocky commented Mar 4, 2021

Overall I really like this. Thanks so much for doing it.
The main question I have is, how can I see the new wonderful behavior? Would you describe something please?
Is there any test I can run to see the difference?
I added some basic tests in te

Overall I really like this. Thanks so much for doing it.
The main question I have is, how can I see the new wonderful behavior? Would you describe something please?
Is there any test I can run to see the difference?

@rocky, please look at test/test_custom_boxconstruct.py to see some very basic tests.

If there are no extra thoughts, observations, or complaints, I would like to merge this during the weekend to finish implementing the pymathics-matplotlib and pymathics-asy.

Will do with pleasure, but I don't I'll have time to look at before the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants