Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!ginosko!uunet!lotus!esegue!compilers-sender From: plogan@pdx.MENTOR.COM (Patrick Logan) Newsgroups: comp.compilers Subject: Re: Compilers For Typeless Languages Message-ID: <1989Sep28.231129.3349@esegue.segue.boston.ma.us> Date: 28 Sep 89 23:11:29 GMT References: <1989Sep21.051232.1868@esegue.segue.boston.ma.us> Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: plogan@pdx.MENTOR.COM (Patrick Logan) Organization: Compilers Central Lines: 60 Approved: compilers@esegue.segue.boston.ma.us In-reply-to: Will@cup.portal.com's message of 21 Sep 89 05:12:32 GMT In article <1989Sep21.051232.1868@esegue.segue.boston.ma.us> Will@cup.portal.com writes: >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. >... > 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] The difference between Will's scenario and Lisp (modern Lisps, anyway) is that Lisp's data is typed. For example, you can't add two numbers together and then concatenate a string to the result. Unless you do something like (string-append (number->string (+ 1 2)) " more characters") which explicitly creates a new string before the concatenation. The "command language" here at Mentor treats variables and data in a way similar to what Will described. To me it is very confusing with little or no benefit, especially if procedures, like "number->string" above, exist to perform conversions where they make sense. Then there is more benefit from a compiler and one can tap into the lore of Lisp and similar languages. In fact, one might choose Lisp or to build the language on top of Lisp. See Byte, 2/88 for more on creating languages within Lisp, and Kranz's PhD dissertation at Yale for more on compiling Lisp-like languages. See also articles on SELF for interesting new work on compiling languages with type-less variables and typed data (like Lisp, Smalltalk, and SELF). They even have application to C++, if you're interested in that sort of thing. These articles have appeared in OOPSLA '87 and SIGPLAN Notices, July 1989. Another will be presented next week at OOPSLA '89. -- Patrick Logan | ...!{decwrl,sequent,tessi}!mntgfx!plogan Mentor Graphics Corporation | plogan@pdx.MENTOR.COM Beaverton, Oregon | "My other computer is a Lisp machine." -- 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.