Subject: Re: Scheme for gluing together applications
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 05 Jan 2003 04:12:07 -0600
Newsgroups: comp.lang.scheme
Message-ID: <5M6cnYUI2YBqmYWjXTWcqA@giganews.com>
Aubrey Jaffer  <agj@alum.mit.edu> wrote:
+---------------
| Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at> writes:
| > I have a 30000 lines of code Fortan 77/90 program (radiation
| > transfer).  It is clear that this program cannot be re-written in C
| > and then included into Bigloo via external bindings.
| 
| I had a bunch of Pascal code written for an extinct platform.  I
| couldn't get the GNU p2c translator to work with the Apollo-Pascal
| extensions.  So I wrote a Pascal-to-Scheme translator
| (http://www.swiss.ai.mit.edu/~jaffer/Docupage/pas2scm.html) and
| processed the code through it.  The resulting Scheme code is editable
| and maintainable.
| 
| I am unfamiliar with Fortran-90.  Fortran-77 should be fairly easy to
| translate to Scheme -- Scheme's support for complex numbers makes it
| friendlier than C.
+---------------

One would also do well to read Kent Pitman's 1979 Macsyma conference
paper <URL:http://world.std.com/~pitman/Papers/Fortran-to-Lisp.html>,
which goes into quite a bit of detail about an "ANSI Fortran"
(Fortran-77?) to MacLisp translater (used with Macsyma), including
a number of design considerations w.r.t. the "Fortran Virtual Machine"
one needs. [Note: By "virtual machine" here he does *not* mean any
kind of slow "byte code" like JVM -- the translater was into Lisp
macros which generated Lisp code which was then compiled into native
PDP-10 machine code that ran at full speed -- but rather the differences
in semantics between the Fortran and Lisp worlds, e.g., subroutine
calling sequences, data representations, etc.]

Anyone considering a Fortran to Scheme (or Common Lisp) translator
should probably read it.

+---------------
| Translating my Pascal code to Scheme exposed some referencing-
| past-the-end-of-array bugs; you should probably expect that for
| Fortran-to-Scheme also.
+---------------

Yup. Pitman also mentioned various issues with aliasing, i.e., the
Fortran EQUIVALENCE statement, COMMON blocks, emulating Fortran
subroutines' "call by reference" (which allows some quite-nasty
dynamic aliasing at run-time), etc.


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607