gjc@mitech.COM (07/03/90)
The fellow was asking about Common-Lisp -> Scheme, not Scheme to commonlisp. I've had to think about this a lot, primarily because we have a large code, Macsyma, which is written in Maclisp, and which we want to extend and develop into the future along side newer code. (Ref: Paradigm Associates Inc, and Lawrence Livermore Labs) All things considered it appears that good quality Scheme implementations are available for more machines than any common lisp. This fact is supported by the obvious engineering implications of the languages: That a good Scheme is easier to implement than a good common lisp. (A good common lisp has to be bad, by it vary nature, in some ways, when size and power/complexity are considered). Be that as it may, the major problem with Common-Lisp -> Scheme translation has been the need to preserve order-of-evaluation of arguments to procedures, and in LET statements. The straightforward translation of (foo (a) (b) (c)) turns into: (let ((temp1 nil)(temp2 nil)(temp3 nil)) (setq temp1 (a)) (setq temp2 (b)) (setq temp3 (c)) (foo temp1 temp2 temp3)) If you have many nested procedure calls you can imagine the mess that generates. It best it ends up making the scheme compiler do tons of extra work in optimizing away those cases that it can, and at worse it results in some very poor code. The maclisp AND/OR construct, which is quite elegantly used in many places in macsyma, e.g. Things along these lines: (defun get-item (a kind) (or (get a 'kind) (get kind 'default))) Where the OR needs to be translated into: (let ((temp1 (get a 'kind))) (if (NOT (NULLP temp1)) temp1 (get kind 'default))) If you decide to do some of your own code-analysis optimization before generating a lot of extra temporaries then you are duplicating functionality that may be in the best scheme compilers. However, none of those compiler will be able to utilize the kind of globally known information about a program like Macsyma which could be handled within the scope of an all-purpose front-end that included a database that was carefully updated as the program was processed. -gjc