OpenMath / py-openmath

An OpenMath 2.0 implementation in Python
MIT License
15 stars 4 forks source link

convert the empty set without using a special case #32

Open MarcoCostantini opened 4 years ago

MarcoCostantini commented 4 years ago

The empty set is converted from Python to OpenMath as <OMS cdbase="http://www.openmath.org/cd" name="emptyset" cd="set1"/> which is correct but not the best choice. It would be better to convert it as <OMA><OMS cdbase=\"http://www.openmath.org/cd\" cd=\"set1\" name=\"set\"/></OMA> it such way, the empty set is handled as a set and not as a special case.

About this, please consider what is said in http://www.catb.org/~esr/writings/taoup/html/ch01s06.html , which is especially relevant for OpenMath, which is intended to be used by computers:

For robustness, designing in tolerance for unusual or extremely bulky inputs is also important. Bearing in mind the Rule of Composition helps; input generated by other programs is notorious for stress-testing software (e.g., the original Unix C compiler reportedly needed small upgrades to cope well with Yacc output). The forms involved often seem useless to humans. For example, accepting empty lists/strings/etc., even in places where a human would seldom or never supply an empty string, avoids having to special-case such situations when generating the input mechanically. -- Henry Spencer One very important tactic for being robust under odd inputs is to avoid having special cases in your code. Bugs often lurk in the code for handling special cases, and in the interactions among parts of the code intended to handle different special cases.