How do I stop recursion happening in a Format/Interpretation Mathematica construction?

前端 未结 1 1957
难免孤独
难免孤独 2020-12-28 20:57

This question follows on from the answer given by Michael Pilat in Preventing “Plus” from rearranging things. There he defined a custom + notation using

相关标签:
1条回答
  • 2020-12-28 21:14

    I consulted with a colleague about this, and his recommendation was essentially that putting up-value definitions on MakeBoxes as you demonstrate is better than using Format when you want things to be tightly integrated from output back to input. Format isn't really intended to produce output that can be re-used as input, but just to format output, hence the unexpected recursion with Interpretation when converting to StandardForm, etc.

    You might find the function ToBoxes a useful complement to MakeBoxes.

    Finally, here's a tutorial about box structures.

    HTH!

    0 讨论(0)
提交回复
热议问题