Advice on translating code from very unrelated languages ​​(in this case, Scheme to Python)?

Reasoning: I'm trying to convert a large library from Scheme to Python

Are there any good strategies for such a conversion? In particular, the cross-paradigm in this case, since Python is larger than OO, and the circuit is functional.

Totally subjective, so I make it a community wiki

+5
source share
5 answers

( , , , ). .

, , - .

+7

. , , , python.

, , :

def test_f():
  assert_equal(library.f(42), reference_implementation('(f 42)'))

, , , , .

, , , , ...

+6

. Python. , @PaulHankin, Python

+1

, , , .

Python , , , , . , , .

0

Write a Python interpreter in Scheme and directly translate your program to this :-) You can start with def:

 (define-syntax def
      (syntax-rules ()
        ((def func-name rest ...)
         (define func-name (lambda rest ...)))))

 ;; test

 (def sqr (x) (* x x))
 (sqr 2) => 4
0
source

All Articles