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.9 required=5.0 tests=BAYES_00 autolearn=ham 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 07:29:34 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dennison@telepath.com (Ted Dennison) Newsgroups: comp.lang.ada Subject: Re: FAQ and string functions Date: 1 Aug 2002 07:29:33 -0700 Organization: http://groups.google.com/ Message-ID: <4519e058.0208010629.5e6182ca@posting.google.com> References: <20020730093206.A8550@videoproject.kiev.ua> <4519e058.0207300548.15eeb65c@posting.google.com> <20020731104643.C1083@videoproject.kiev.ua> NNTP-Posting-Host: 65.115.221.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1028212173 11559 127.0.0.1 (1 Aug 2002 14:29:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 1 Aug 2002 14:29:33 GMT Xref: archiver1.google.com comp.lang.ada:27571 Date: 2002-08-01T14:29:33+00:00 List-Id: Oleg Goodyckov wrote in message news:<20020731104643.C1083@videoproject.kiev.ua>... > strings. In Booch components set in demo files is present file > bcwords.ada. Look at it. It contains full program for counting and > printing of frequencies of words met in any given text file. But this file > - bcwords.ada - begins from 15-line Perl's program, which does the same > work. Look there, compare volumes of Perl's and Ada's programs, and think, > why difference is so dramatically big in favor of Perl? That's odd. All you'd really have to do to do this in Ada would be: 1) Read file into a string 2) Call Ada.Strings.Fixed.Count on the string Doing 1 could be tricky, if you have no idea how big the file is. But there are techniques for dealing with that. My personal favorite is the recursive growing string trick. That only takes about 5 lines of code. You could also use Ada.Streams.Stream_IO to open and find the length of the file and String'Read to read it all into one perfectly sized string. Doing 2 is a one-liner. > 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 Well, it should be hardly shocking that the "standard" Perl has more string handling goodies than the standard Ada. Perl was made for string handling. If it can't even beat a compiled general-purpose programming language like Ada in this reguard, it should give up its scripting credentials and go run security in airports or something. However, you are right that much of this *can* be done in Ada. If you want more powerful string parsing capabilities, there are lots of options for you. One good one (which I see has already been mentioned) is the Gnat string handling packages. They provide very powerful pattern matching capability, which is probably the style of working you are used to if you are a Perl user. The main drawback to this is that it isn't avilable to you if you are using a compiler other than Gnat (iow: it's not compiler-portable). Another, even more powerful option, if you need something really sophisiticated, is the OpenToken packages (http://www.telepath.com/~dennison/Ted/OpenToken/OpenToken.html ). They are written in standard Ada, and should be portable to any compiler (although there have been minor issues in the past). > So, by all of diversity of GENERIC string's handling tools in Ada, > convinient tool is not present. Well, we are currently looking at beefing up the standard library for the next version of the language. Perhaps you are saying you believe string handling needs attention? -- T.E.D. Home - mailto:dennison@telepath.com (Yahoo: Ted_Dennison) Homepage - http://www.telepath.com/~dennison/Ted/TED.html