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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f316de357ae35e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-01 02:51:04 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-035-104.arcor-ip.NET!not-for-mail From: Dmitry A.Kazakov Newsgroups: comp.lang.ada Subject: Re: FAQ and string functions Date: Thu, 1 Aug 2002 23:57:04 +0200 Message-ID: References: <20020730093206.A8550@videoproject.kiev.ua> <20020731104643.C1083@videoproject.kiev.ua> <20020731182308.K1083@videoproject.kiev.ua> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-035-104.arcor-ip.net (145.254.35.104) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1028195463 37017239 145.254.35.104 (16 [77047]) User-Agent: KNode/0.4 Xref: archiver1.google.com comp.lang.ada:27558 Date: 2002-08-01T23:57:04+02:00 List-Id: Oleg Goodyckov wrote: > On Thu, Aug 01, 2002 at 12:04:38AM +0200, Dmitry A.Kazakov wrote: >> Oleg Goodyckov wrote: >> >> > If we look at that Ada program carefully, we'll see, that half of it >> > takes subprogram Get_Next_Word. What it does? It's clear from name - it >> > parses next word from line. How it is done in Perl program? Simple - by >> > splitting of line on words by space as delimiter. So, while on Ada we >> > must make slice, "Array_Name(5..8)", loop, if, and other very important >> > stuff, in >> > Perl we say @list=split(/ /,String) and that's all. Is this Perl's own >> > especiality? No. It can be realized in Ada. And I say more - without >> > this Ada will never be convinient language. >> >> For which use? I would definitely not use something like split for >> parsing. It is extremely inefficient. Ada was not designed for >> write-once-use-once programs. > > Ok! How about write-once-use-always? For text data analyze applications. Then, maybe it is worth to consider more advanced parsing techniques than split? There are numerous Ada implementations of pattern matching. There are also Ada subprograms to recognize data types in a string stream. It is relatively easy to parse and evaluate expressions with brackets and prioritized operations in Ada (an implementation of the twin-stack argorithm is quite short) and note no things like split involved. >> > While for splitting string like >> > "x=2*3" people will must be to write program enstead >> > split("=","x=2*3"), people will write in Perl, not Ada. >> >> And what would you do in the case "x=/* An error, should be := */ 2*" and >> "3" continues on the next line? > > Nothing. I know: I have data as described. If no - data is corrupted and > must be throwed out. It's simple. To do so you should have an ability to recognize errors. > But what would you do in the case, when data is correct yet? In the given example data are correct. /*...*/ was a comment containing a symbol supposed to be a delimiter. My point was that for almost any real-life text parsing application, split is useless. > You'll build PROGRAMMMM, instead write "split(/=/,"x=2*3")". You still need a program to process the output of split. Is its output the final outcome? I suppose it is not. So there should a loop to iterate through the list returned by split. Where is then a difference between split + loop, and loop with Get_Next_Word inside? IMO, the difference is that the second is faster and easier to understand. -- Regards, Dmitry Kazakov www.dmitry-kazakov.de