| [Mumps2Py:] Mumps to Python Naive translation notes #1 | 
[ Thread Index | 
Date Index
| More lists.mumps2py.org/discuss Archives
] 
while piecemeal translation of  Mumps to python  seems relatively 
straightforward (at least so far),
the truth of the matter is that Mumps does not have the exact same 
semantics as Python and vice-versa.
One example is that extracting the -1 character of a string is 
meaningless in Mumps, whereas in Python it means extract the last 
character of a string.
Another example is the equivalence of Python's print command to Mumps' 
WRITE command.
print x,y,z,  is almost equivalent  to  WRITE  x,y,z except that print  
will add a  space between each argument. If you don't want spaces 
between the arguments written out, then you should join the strings 
together.  For strings all you have to do is x+y+z to get a joined 
string.  However, in Python, you can't join strings with numbers; you 
first have to convert the number to a string, either using str() or the 
modulo operator to produce a formatted string.
I see essentially two approaches that can be taken  to address this problem:
1. Translate  Mumps expressions into the  most equivalent  Python 
statement, realizing that  this naive translation *will* introduce bugs 
into all but the most trivial of programs.
2. Instead of translating directly to Python, translate to a 
compatibility library with classes and functions which implement the 
same semantics as Mumps.
I think that Mumps2Py has to implement both approaches.
I think that the naive approach needs to be the dominant one because the 
goal of the translation is to use it as a starting point for change 
(adding functionality, restructuring functionality for maintainability, 
optimizing performance), and the task will be that much harder if the 
maintainer has to work around compatibility layer crud.
At the same time, a behavior-faithful translation to compare against 
should be helpful when fixing up a naive translation.
That's what I think at this point anyway.
Cheers,
-Patrick
---