From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, STOX_REPLY_TYPE autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 5b1e799cdb,3ef3e78eacf6f938 X-Google-Attributes: gid5b1e799cdb,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!feed-me.highwinds-media.com!cyclone02.ams2.highwinds-media.com!news.highwinds-media.com!pe1.news.blueyonder.co.uk!blueyonder!text.news.virginmedia.com!53ab2750!not-for-mail From: "bartc" Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.modula3,comp.lang.pascal.misc,comp.programming References: <4a6a2335.7649091@news.individual.net> In-Reply-To: Subject: Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3? MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6000.16480 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16669 Message-ID: <0NXam.60897$OO7.41820@text.news.virginmedia.com> Date: Sun, 26 Jul 2009 12:14:52 GMT NNTP-Posting-Host: 82.42.208.18 X-Complaints-To: http://netreport.virginmedia.com X-Trace: text.news.virginmedia.com 1248610492 82.42.208.18 (Sun, 26 Jul 2009 13:14:52 BST) NNTP-Posting-Date: Sun, 26 Jul 2009 13:14:52 BST Xref: g2news2.google.com comp.lang.eiffel:432 comp.lang.ada:7362 comp.lang.modula3:115 comp.lang.pascal.misc:313 comp.programming:12053 Date: 2009-07-26T12:14:52+00:00 List-Id: "tm" wrote in message news:ffe34647-ed6d-4349-beb1-3f613351439d@v36g2000yqv.googlegroups.com... > On 25 Jul., 00:29, "bartc" wrote: >> "Wolfgang Ehrhardt" >> wrote in messagenews:4a6a2335.7649091@news.individual.net... >> >> > On Fri, 24 Jul 2009 00:26:11 -0700 (PDT), tm >> > wrote: >> >> >>I once met somebody, who wrote the front end of an Ada compiler, and >> >>he told me a different story. E.g.: He said that a special function >> >>needs to read ahead just to find out the semantic of a parenthesis. >> >>In Pascal such read ahead is not necessary. >> >> > Of course a read ahead is necessary in Pascal (at least in a one-pass >> > compiler), otherwise the following would give an error: >> >> > procedure test (*comment*) (x: integer); >> >> I think Pascal doesn't need lookahead if it's dealing with symbols rather >> than characters. Even with characters only a single character lookahead >> is >> needed. > > Agree. > >> Possibly Ada may need to read multiple symbols ahead. >> >> The Pascal design is elegant but I've done parsers where potentially >> thousands of tokens need to be processed after a parenthesis before it >> knows >> exactly what it's dealing with. It's not a problem. > > The problem is not that it is not doable. > The problem is that human readers must also process > thousands of tokens to know exactly what is going on. This really means it needs to look ahead a complete expression, which can be of arbitrary complexity, especially if expressions can include statements as my design did. Examples: (expr) # ordinary parenthesised expression (expr | a | b) # if-then-else select (expr | a,b,c | z) # n-way select (expr, a,b,c) # list a[expr] # normal indexing a[expr..expr] # slicing etc... In practice expr will be short and only a few symbols (such as n+1). If the user wants to put almost a whole program in there, that's up to him. And he could probably do similar things in Pascal and Seed7. > When one symbol tells you, what is going on, reading is easier. > Complicated parsing with lookahead is IMHO an indication > for hard to read constructs. You can't argue the above construct's aren't easy on the eye. On the other hand: switch n when x then a when y then b else c end [i]:=k is probably ill-advised. It's not until the end that you realise it's an assignment to an array element (ie. assigning k to one of a[i], b[i] or c[i]). So it all depends. Parsing this stuff is trivial. Might as well make it available, and trust the user to use it sensibly. -- Bart