Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.linkpendium.com!news.linkpendium.com!news.iecc.com!.POSTED!nerds-end From: Martin Ward Newsgroups: comp.compilers Subject: Re: Programming language and IDE design Date: Tue, 3 Dec 2013 15:15:07 +0000 Organization: Compilers Central Lines: 40 Sender: johnl@iecc.com Approved: comp.compilers@iecc.com Message-ID: <13-12-003@comp.compilers> References: <13-11-016@comp.compilers> <13-11-018@comp.compilers> <13-11-031@comp.compilers> NNTP-Posting-Host: news.iecc.com Mime-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: leila.iecc.com 1386209259 61678 64.57.183.58 (5 Dec 2013 02:07:39 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Thu, 5 Dec 2013 02:07:39 +0000 (UTC) Keywords: syntax, design Posted-Date: 04 Dec 2013 21:07:39 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:1058 On Sunday 24 Nov 2013 at 23:33, "robin" wrote: > > AFAIK, Fortran's DO loop requires the most lookahead of any of the > > classic language features: LL(4) [if I'm counting correctly]. > > > > 10DOI=42 > > 10DOI=42,45 > > The statements are > DO 10 I = 42 > DO 10 I = 42, 45 The difference is even smaller than this: DO 10 I = 42.45 DO 10 I = 42,45 The first is an assignment of a floating point value to variable DO10I, the second is a loop with I as the loop variable. Fortran allows spaces in the middle of identifiers, so requiring spaces around keywords does not help (unless you *also* disallow spaces within identifiers). The fact that the two statements can be distinguished with an LL(k) parser does not necessarily mean that the language is easy to read. Disallowing spaces within identifiers, insisting on spaces around keywords, insisting on correct indentation and correct and distinct closing keywords to block structures, and requiring all identifiers to be declared with an appropriate type, all make the language harder to write: but also easier for humans to read (even if they make no difference to the language parser). Any, or all, of these restrictions would have prevented the confusion between an assignment and a loop. -- Martin Dr Martin Ward STRL Principal Lecturer and Reader in Software Engineering martin@gkc.org.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4 G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/ Mirrors: http://www.gkc.org.uk and http://www.gkc.org.uk/gkc