Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.misty.com!news.iecc.com!.POSTED!nerds-end From: glen herrmannsfeldt Newsgroups: comp.compilers,comp.unix.shell,comp.os.linux.misc Subject: Re: magic/absurd bash interpreter/compiler ? Date: Tue, 25 Dec 2012 03:25:01 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 37 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <12-12-020@comp.compilers> References: <12-12-014@comp.compilers> <12-12-018@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: leila.iecc.com 1356477409 61242 64.57.183.58 (25 Dec 2012 23:16:49 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Tue, 25 Dec 2012 23:16:49 +0000 (UTC) Keywords: interpreter, design Posted-Date: 25 Dec 2012 18:16:49 EST X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com Xref: csiph.com comp.compilers:804 comp.unix.shell:6262 comp.os.linux.misc:6898 In comp.compilers Eric wrote: (snip) > Why on earth would you expect all computer languages to parse with a > single pass from left to right? Neither Pascal nor Forth is a typical > computer language. Pascal has more-or-less the sort of parser you seem > to think should be universal, Forth does not! Bash (like other shells) > is an interactive command-line based user interface which can also be > used to write scripts, and it has evolved over many years, so why would > it be like that? (snip, our moderator wrote) > [I've had a lot of questions from people who seem unclear on the > difference between an interpreter and a compiler, and get confused as > soon as the language gets complex enough that it can't be handled a > line at a time by read-parse-interpret. Most languages I know can indeed > be parsed in a single left to right pass, but all you have at that point > is a parse tree, with a lot of the compiler's work left to do. -John] There are many interpreted languages that pretty much can't be compiled, at least in the usual sense of compilation. Especially in shell languages, but also ones like TeX and Mathematica, where you can expand variables to be keywords that are then parsed. I once wrote self-modifying code in Mathematica. Someone wanted, in the and, a Mathematica notebook with all the results and graphs, but not with the Mathematica code. I wrote the code that asks the front end to delete the code from the notebook. (Be sure to save before testing during debugging.) TeX has \expandafter which allows for run-time generation of names of macros to execute. One problem with many unix shells is that redirection is done too early. Specifically, before an if test is done. -- glen