-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
Parse string arguments in ToString #574
base: master
Are you sure you want to change the base?
Conversation
Go back to using master branch in scanner
583e8ee
to
0417a44
Compare
No, it does not exists (I tested it). And, as I showed before, MakeBoxes does not use that information to build a Boxed expression. It happens afterwards (when Boxes are converted into text strings)
Also, this does not happen in WMA. Otherwise, it would come up in my tests. In some way, |
mathics/builtin/atomic/strings.py
Outdated
# runs ToString[] on the resulting M-expression. | ||
session = MathicsSession() | ||
try: | ||
expr = parse(session.definitions, MathicsSingleLineFeeder(expr.value)) |
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.
really do you want to create a session to convert a string?
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.
Yes, I suppose it is better to just Definitions. I am not sure though if we want add_builtin
set True
or False
. You tell me.
The thought here was to use a clean slate of the definitions, and not modification made to the built-in functions.
But you tell me, does ToString
behavior of an expression change if there has been an altered behavior to built-in function functions or other functions added which appear in the string part of ToString
?
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.
MakeBoxes does not use that information to build a Boxed expression.
I wasn't intending to imply that. Instead, there is ToString
that accepts an encoding parameter. In the course of doing, ToString
calls boxes_to_text()
which triggers MakeBoxes
.
Right now MakeBoxes
performs formatting of operators before it returns. We need to get the information through to the formatter that MakeBoxes
is invoking . In a functional approach which is what would be preferred here, this would passed via the function call arguments somehow.
It happens afterwards (when Boxes are converted into text strings)
Currently in Mathics, Boxing and Formatting can be interleaved. So right now there is no absolute "afterwards".
In Wolfram Alpha are there ever situations where Boxing and Formatting are interleaved?
Removing this interleaving in Mathics would require a major refactoring of our code. If that needs to be done, I think we need to reduce our goals for the time being and set a more easily-achievable bar to reach.
that apparently is all we need.
In order to dig deeper into |
This is a little closer to the correct behavior when
ToString[]
is passed a string argument.We currently can't handle passing an "encoding" parameter to
ToString[]
, for example:The main obstacle here is understanding how go get the desired encoding passed down via the direct call to
MakeBoxes
down to formatting where this should be used.WMA does not explicitly list
CharacterEncoding
as an option toMakeBoxes
. Does it exist and is not documented? Assuming it does not exist, how would WMA pass this information down?However it is done, in our current code base, we do not have such a feature, short of changing
$CharacterEncoding
which we should avoid doing.