Re: Convert imperative to functional?

Joachim Durchholz <joachim.durchholz@web.de>
31 Oct 2003 23:02:53 -0500

          From comp.compilers

Related articles
Convert imperative to functional? huangyue@pmail.ntu.edu.sg (#HUANG YUE#) (2003-10-27)
Re: Convert imperative to functional? joachim.durchholz@web.de (Joachim Durchholz) (2003-10-31)
Re: Convert imperative to functional? torbenm@diku.dk (2003-10-31)
| List of all articles for this month |
From: Joachim Durchholz <joachim.durchholz@web.de>
Newsgroups: comp.compilers
Date: 31 Oct 2003 23:02:53 -0500
Organization: Oberberg Online Infosysteme
References: 03-10-117
Keywords: functional, theory
Posted-Date: 31 Oct 2003 23:02:53 EST

#HUANG YUE# wrote:
> He asked me whether it is possible to convert imperative back to
> functional structures? Easy for program analysis?


Just as with all program transformations: You can convert Fortran to
Pascal, but the resulting Pascal program will still be Fortran - in
other words, it will still exhibit all the quirks and problems of the
Fortran code, complicated by whatever hoops the conversion algorithm
had to jump through to get the semantics translated.


So, it's not possible to make analysis easier by transforming to
functional code.


Stating it in another way: if the program transformer is indeed able
to transform imperative code into functional code, then any
improvements due to a "more functional style" will have required the
exactly same analysis that you spare if you can work with functional
code directly.


> Is there some compiler able to do such similar thing?


Probably there are several, at wildly varying degrees of quality.


  > Is it a fresh idea?


It's quite old. Actually, the same problems and answers apply to the
question how to transform an unstructured program into its GOTO-less
equivalent, so this question predates my birth.


  > Or ridiculous?


No, the idea isn't ridiculous. It's just not (sensibly) feasible.


> I lack the knowledge in this area and feel eager to accept any
> related answer.


Hope this helped,
Jo


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.