grzegorzmazur / yacas

Computer calculations made easy
http://www.yacas.org
GNU Lesser General Public License v2.1
124 stars 24 forks source link

Two OpenMath objects together #299

Closed MarcoCostantini closed 4 years ago

MarcoCostantini commented 4 years ago

This produces two OpenMath objects together, and a parser that receives this would complain:

$ yacas 
True;
This is Yacas version '1.8.0'.
[...]
In> PrettyPrinter'Set("OMForm")
<OMOBJ>
  <OMS cd="logic1" name="true"/>
</OMOBJ>
In> OMForm(3)
<OMOBJ>
  <OMI>3</OMI>
</OMOBJ>
<OMOBJ>
  <OMS cd="logic1" name="true"/>
</OMOBJ>
grzegorzmazur commented 4 years ago

Hi,

Ok, I think that there might be some misunderstanding here. When you call PrettyPrinter'Set("OMForm"), you're not expected to subsequently call OMForm() later on. So I'd rewrite your example as

$ yacas
True;
This is Yacas version '1.8.0'.
Yacas is Free Software--Free as in Freedom--so you can redistribute Yacas or
modify it under certain conditions. Yacas comes with ABSOLUTELY NO WARRANTY.
See the GNU Lesser General Public License (LGPL) version 2.1 or (at your
discretion) any later version for the full conditions.
Type ?license or ?licence to see the LGPL version 2.1;
See http://www.yacas.org/ for more information on yacas. and documentation.
Type ?? for help. Or type ?function for help on a function.

To exit Yacas, enter  Exit(); or quit or Ctrl-c.
Type 'restart' to restart Yacas.
To see example commands, keep typing Example();
In> PrettyPrinter'Set("OMForm")
<OMOBJ>
  <OMS cd="logic1" name="true"/>
</OMOBJ>
In> 3
<OMOBJ>
  <OMI>3</OMI>
</OMOBJ>
In> 

Note that there's no stray True.

If you prefer to use OMForm() explicitly, do so without setting the printer, like so

$ yacas
True;
This is Yacas version '1.8.0'.
Yacas is Free Software--Free as in Freedom--so you can redistribute Yacas or
modify it under certain conditions. Yacas comes with ABSOLUTELY NO WARRANTY.
See the GNU Lesser General Public License (LGPL) version 2.1 or (at your
discretion) any later version for the full conditions.
Type ?license or ?licence to see the LGPL version 2.1;
See http://www.yacas.org/ for more information on yacas. and documentation.
Type ?? for help. Or type ?function for help on a function.

To exit Yacas, enter  Exit(); or quit or Ctrl-c.
Type 'restart' to restart Yacas.
To see example commands, keep typing Example();
In> OMForm(3)
<OMOBJ>
  <OMI>3</OMI>
</OMOBJ>
Out> True

BTW, here you see why there were two OMOBJs generated in your example -- OMForm() generates the OpenMath string as a side effect, and returns True. If you call OMForm() with printer set to OMForm(), the former will translate the argument, display it and return True, which will be translated by the latter (within printer mechanism) which will generate subsequent OMOBJ.

I hope that I've understood your report correctly, and that my explanation is sufficient to close the issue. But I'll leave it open for now, so if you think that something still has to be done about it, please comment.

Cheers, Grzesiek