Converting languages to a purely functional form

Dobes Vandermeer <dobes@dobesland.com>
15 Jul 2003 23:40:56 -0400

          From comp.compilers

Related articles
Converting languages to a purely functional form dobes@dobesland.com (Dobes Vandermeer) (2003-07-15)
Re: Converting languages to a purely functional form joachim.durchholz@web.de (Joachim Durchholz) (2003-07-17)
Re: Converting languages to a purely functional form derkgwen@HotPOP.com (Derk Gwen) (2003-07-17)
Re: Converting languages to a purely functional form dobes@dobesland.com (Dobes Vandermeer) (2003-07-21)
Re: Converting languages to a purely functional form pat@jantar.org (Patryk Zadarnowski) (2003-07-21)
Re: Converting languages to a purely functional form vidar@hokstad.name (2003-07-21)
Re: Converting languages to a purely functional form lars@bearnip.com (2003-07-23)
[2 later articles]
| List of all articles for this month |

From: Dobes Vandermeer <dobes@dobesland.com>
Newsgroups: comp.compilers
Date: 15 Jul 2003 23:40:56 -0400
Organization: Compilers Central
Keywords: translator, functional
Posted-Date: 15 Jul 2003 23:40:56 EDT

Purely functional programs are, as far as I can tell, much easier to
operate on programmatically than regular procedural ones. Loops,
destructive updates, etc. make many kinds of very powerful analyses
rather difficult.


This makes a pure functional language useful as a kind of intermediate
representation.


To eliminate destructive updates, you'd have to change every function so
that it took in each global/member variable it read, and returned every
one that it wrote.


To eliminate loops, you'd have to replace them with tail-recursive
function calls.


To eliminate goto & break you'd have to add conditionals to escape and
enter blocks.


The main problem here, is that once you've analysed all the data flow
information you get from this conversion, you'd want to be able to
generate efficient code anyway; e.g. you's still want to generate loops,
not tail-recursive function calls. This might entail some serious
additional optimizations/analyses just to get back where you started.


Thoughts/Comments/References?


Post a followup to this message

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