kramer@cme.nbs.gov (Tom Kramer) (05/30/89)
I have translated a few hundred lines of Franz Lisp code into Common Lisp. I had written the Franz code myself. For stylistic reasons (I always used def rather than defun in Franz), not one function could be used as as is. Even without the style problem, only the simplest functions (one or two lines of car's, cdr's, mapcar's, etc.) could be used without alteration. Around the end of 1988 I inquired from Franz, Inc. whether they had any programming aids to give to users for translating Franz to Common. They did not. I have not heard of a translator program. To write a translator that would handle a moderately complex (50 twenty-line functions) software system in Franz with only a few errors and inefficiencies, would take several months solid work, I think. On the other hand, a translator limited to, say, 50 of the most used Franz functions that differ only slightly from Common functions of the same name or have differently named but similarly behaved counterparts could be banged out in a few days. I wrote a brief (5 pages) comparison of Franz and Allegro Common for my own use. It covers about 200 Franz and Common functions, with one line per function. I will be glad to send it to E-mail requestors.
adams@crcge1.UUCP (Drew Adams) (06/01/89)
In article <1196@cayman.cme.nbs.gov> kramer@cme.nbs.gov (Tom Kramer) writes: > >Around the end of 1988 I inquired from Franz, Inc. whether they had any >programming aids to give to users for translating Franz to Common. They >did not. >I have not heard of a translator program. To write a translator that would >handle a moderately complex (50 twenty-line functions) software system in >Franz with only a few errors and inefficiencies, would take several months >solid work, I think. --------------------------------------- In 1984 I wrote a translator program, FTOC (Franz To Common), which has been used a bit here and elsewhere, since. It (source) is available to anyone for "research" (i.e. non-commercial) purposes. It was written for an old version of Franz (I forget which). The basic program works fine, but its correctness depends on the correctness of the set of rewrite rules used to define the language-language translation. These could be improved, and some are even known to be incorrect. No guarantees are made, of course. The program works by simple macro-expansion (but not evaluation), i.e. "reduction". It may also be used for any other (Lisp-like) language-language translation. (You'll need to define the rewrite rules. Yes, THAT is a lot of work -- it means translating every language expression, if you want a "complete" translator.) No translation program is satisfactory, obviously (there are lots of untranslatable things). FTOC tries to be prudent, rather than clever; whenever possible it tries to maintain the semantics of the original code, rather than "optimizing". Different, more liberal, rewrite rules could of course be used. FTOC is written in Common Lisp, and has run on VAX with VAX-VMS Common Lisp, and on Sun with KCL and Lucid. No claims on portability are made, but I don't recall it using any implementation-dependent features. FTOC does use the Common Lisp reader, so some porting problems may arise regarding character case, filenames etc. FTOC may be used interactively, as well, as a sort of (slow) Franz front end to Common. This is sometimes useful when Franz programmers start to learn Common -- Franz expressions may be translated on the fly and, optionally, executed in Common. In addition to the source, a User's Guide is available. I will try to respond to requests for the program promptly, but I'm a bit overloaded with work, so ... A few remarks: FTOC should be regarded as an AID to translation, rather than an automatic translator. The biggest difference between Franz and Common is that Common uses static scoping of variables (in general). Franz code which depends on dynamic scoping cannot, generally, be translated (automatically). FTOC makes no attempt to wrestle with this problem; it is ignored. Type predicates, after translation, refer to COMMON Lisp types. For example, the Franz predication (BIGP ...) is translated to the Common predication (TYPEP BIGNUM ...) Franz code which manipulates or produces CODE which is SPECIFICALLY Franz will normally NOT work, of course, after translation to COMMON. However, FTOC users may optionally choose to have macro definitions expanded during translation. This may help in some cases. Whenever an expression translation is not straightforward (the result isn't immediately recognizable as a translation of the input by the programmer), the result code is enveloped and labelled for recognition, with an FLET. That is, temporary named functions are created, whose names correspond to the source code names (prefixed by "FRANZ"). Further info on the correspondance is available using the Common Lisp function DOCUMENTATION. Finally to show one of the worst kinds of thing that can happen, because of the desire not to modify the original semantics, here is the Common Lisp code resulting from the Franz expression (+ 2 (+ 3 (+ 4 1))): [Things aren't normally this bad!] (flet ((franz.+ (&optional (n1 0) &rest n2etc) "equivalent to Franz Lisp '+'." (check-type n1 fixnum) (mapc #'(lambda (n) (check-type n fixnum)) n2etc) (if (endp n2etc) n1 (+ n1 (reduce #'+ n2etc))))) (franz.+ 2 (flet [.... AS ABOVE ...] (franz.+ 3 (flet [.... AS ABOVE ...] (franz.+ 4 1)))))) -- Drew ADAMS, Laboratoires de Marcoussis, Centre de Recherche de la Compagnie Generale d'Electricite, Route de Nozay, 91460 MARCOUSSIS, FRANCE Tel. 64.49.11.54, adams@crcge1.cge.fr
kend@tekchips.LABS.TEK.COM (Ken Dickey) (06/02/89)
In article <1196@cayman.cme.nbs.gov> kramer@cme.nbs.gov (Tom Kramer) writes: > >I have translated a few hundred lines of Franz Lisp code into Common Lisp. ... You might be interested in "Porting Pan I to Allegro COMMON Lisp", Darrin Lane, Report # UCB/CSD 88/453, September, 1988 {U of Calif., Berkeley}. It describes a port of an 18000 line program from Franz to Allegro and covers file & buffer i/o, keystroke handling, etc. and has a set of example macros in the appendix. Not a panacea, but seems a reasonable description of the issues. -Ken Dickey