Path: utzoo!attcan!telly!lethe!torsqnt!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!haven!uvaarpa!mcnc!decvax!ima!esegue!compilers-sender From: Will@cup.portal.com Newsgroups: comp.compilers Subject: Compilers For Typeless Languages Message-ID: <1989Sep21.051232.1868@esegue.segue.boston.ma.us> Date: 21 Sep 89 05:12:32 GMT Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: Will@cup.portal.com Organization: Compilers Central Lines: 48 Approved: compilers@esegue.segue.boston.ma.us Do any of you who have written interpreters or compilers for typeless languages have any thoughts on whether it is worthwhile to even bother writing a compiler for the language? Let's say I have a language, X, where every variable is treated by the user as a character string, and the interpreter knows that in certain contexts a string implies a non-character type of data and operation (e.g., "2/3", "3.343434 * 23423.23423"). The user doesn't ever declare a variable to be of any type; datatypes are implied by the use of a variable. Since in many situations there is no a-priori way to know whether a variable is going to be used exclusively as a character type, integer, or floating point type, a compiler for such a language would need to include run-time support to determine the way in which variables were being used as statements are executed. Since you need this run-time support, some might argue, your compiler is essentially an interpreter and why bother to write the compiler at all? With that background, the question is are there other reasons to write a compiler for such a language? A few possible reasons that come to mind: 1) in certain contexts your compiler could determine that a variable was used exclusively as an int or floating type and declare it that way in order to be able to do the math using machine instructions instead of subroutine calls for math operations; 2) you could optimize those parts of the code that were machine code; 3) you could include pragmas that let a programmer instruct the compiler that if a variable is used exclusively for math in a subroutine that the compiler should assume that correctly "typed" arguments were passed to the routine (hence, you gain the benefits of 1 and 2); 4) you could let the user compile his code for different target processors (e.g. 8086, 80286, 80386, 80486) instead of forcing the least common denominator (8086) because that's what your interpreter was compiled to use in order to be able to run on any 80x86 platform. Are these valid reasons to build a compiler for a typeless language? Are there other reasons? Would one expect to get substantial performance benefits? Will [These issues have been hashed over in the Lisp community for 30 years, and most Lisp systems include compilers. Anybody have some good references on compilation issues? -John] [From Will@cup.portal.com] -- Send compilers articles to compilers@esegue.segue.boston.ma.us {spdcc | ima | lotus}!esegue. Meta-mail to compilers-request@esegue. Please send responses to the author of the message, not the poster.