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-Thread: 103376,8f802583e5c84fa X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news1.optus.net.au!optus!newsfeeder.syd.optusnet.com.au!news.optusnet.com.au!newsfeed.pacific.net.au!nasal.pacific.net.au!not-for-mail Newsgroups: comp.lang.ada Subject: Re: String filtering From: David Trudgett Organization: Very little? References: <1j92wa9843ylq.16j89wuqatbaj$.dlg@40tude.net> Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:e8B4uyCkQVVmH8R52yJwWWBlAqk= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Wed, 28 Sep 2005 11:01:43 +1000 NNTP-Posting-Host: 61.8.35.118 X-Complaints-To: news@pacific.net.au X-Trace: nasal.pacific.net.au 1127869581 61.8.35.118 (Wed, 28 Sep 2005 11:06:21 EST) NNTP-Posting-Date: Wed, 28 Sep 2005 11:06:21 EST Xref: g2news1.google.com comp.lang.ada:5213 Date: 2005-09-28T11:01:43+10:00 List-Id: Jacob Sparre Andersen writes: > David Trudgett wrote: >> Dmitry A. Kazakov wrote: >>> On Tue, 27 Sep 2005 19:13:17 +1000, David Trudgett wrote: > >>>> New_Str : Unbounded_String >>>> := To_Unbounded_String(Count(Str, Alphanumeric_Set)); >>> >>> If you do this, then use String (1..Count (...)); >> >> If I did that then I would need to convert back to unbounded_string >> when I return the function result. Would that be significantly >> faster than working on a pre-allocated unbounded string? > > I think it would, but it clearly depends on the implementation of > Ada.Strings.Unbounded. You may be right about that, but there is probably irreducible complexity in unbounded strings. For my particular current purposes, there is nothing between them performance-wise. > >>> Either, you need a character *stream* filtering, >> >> Possibly, but I'm not using a socket stream interface at the current >> time. The socket library I'm using right now doesn't do streams. > > It definitely looks like an ideal example for the use of streams. Is > there something that makes it a bad idea to switch to a stream-capable > socket package? Only the fact that I'm just toying with a game program, and the socket library already works (adasockets 0.1.6 IIRC), and the comms layer I wrote works on top of it. Changing it in future won't be any big deal, however, since it's abstracted away behind my comms layer. > You should use the programming styles supported by Ada, when you're > programming in Ada. Yes, indeed. > Otherwise it may be very frustrating to program in Ada. For > functional programming you should use SML, Erlang, OCaml or another > "proper" functional programming language. Well, I don't do pure "functional" as some people define it. I only tend in that direction where I find it helpful. Ada is very much procedural, however. David -- David Trudgett http://www.zeta.org.au/~wpower/ No one is given a map to their dreams All we can do is to trace it. See where we go to, know where we've been Build up the courage to face it. -- Sandy Denny