Compilers For Typeless Languages
Wed, 20-Sep-89 11:24:51 PDT

          From comp.compilers

Related articles
Compilers For Typeless Languages (1989-09-15)
Re: Compilers For Typeless Languages (Stephen Adams) (1989-09-23)
Re: Compilers For Typeless Languages plogan@pdx.MENTOR.COM (1989-09-28)
| List of all articles for this month |

Date: Wed, 20-Sep-89 11:24:51 PDT

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?

[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]

Post a followup to this message

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