Why is it not possible to create a practical Perl to Python source code converter? -
It would be nice if a program exists that automatically converts the Perl code into Python code, resulting in the reading program Readable and satisfactory as the original one, keep working alone.
The most obvious solution would be to call only through the perl
dragon utils:
#! / Usr / bin / python os.exec ("Tail-N-2" + __ file __ + "| Pearl-") ... the rest of the file is the original Perl program ...
However, the resulting code is hardly a Python code, it is essentially a Perl code potential converter must convert the Python code to Perl construction and easy-to-read phrases, it must have variable and suburban name ( I.e. the result should not be ambiguous) and do not break too much wrokflow.
This conversion will depend on clearly very difficult number of conversion of hardness Pearl features and syntax creative structures, which do not have an easy-to-read, Anbossketed Python equivalent. I believe that such a large amount of such automatic conversion is impossible practically (while the theoretical probability exists).
So, can you please name Pearl, idioms and syntax features can not be expressed as a python like the original Pearl code?
Edit : On the basis that some people are connected to Python-to-Pearl Conventors, it should be easy to write Pearl-to-Python too. However, I'm sure to Python has more in demand; This converter is not written yet - while the reverse has already been done! Which only makes me a better converter in the unlikely possibility of writing Python more concrete
Just to expand here in some other lists, these are some of the Pearl Structures which could possibly be very much in Python Adhesive (if possible).
- Dynamic area (via
local
keyword) - Typographic manipulation (multiple variables with the same name)
- Pargama
- Livelih sub-routine (
-
mysub () = 5;
type code) - source filter
- reference (list vs. scalar
,
- type sign / Dynamic typing
- Any program that uses string
eval >
- Code>
Su Chi continues, and any one can try to make a mapping between all structures, but in the end this failure will be a simple reason.
Pearl can not be permanently parsed is. Perl code definitions (especially in the BEGIN block to those who) way changes the way an understanding compiler latest code. Therefore, non-trivial programs, Perl => suspend conversion of Python Problem
There is no way to know exactly how all the programs will be compiled until the program is completed, and it is theoretically possible to create a pell program that is used every time it Running Which means that a Perl program can map an infinite number of Python programs, which is correct only after running the original program in Perl interpreter only.
Comments
Post a Comment