Re: String filtering



Jacob Sparre Andersen <sparre@xxxxxx> 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

.



Relevant Pages

  • Re: String filtering
    ... > faster than working on a pre-allocated unbounded string? ... It definitely looks like an ideal example for the use of streams. ... but I like functional programming better. ... > programming in Ada so far, having been thwarted by strong typing and ...
    (comp.lang.ada)
  • Re: Advantages
    ... In most programming languages, including C for example, under a typical ... When it has finished, it resets the semaphore ... In Ada 95, you would typically use a protected object to protect the ...
    (comp.lang.ada)
  • Re: Current status of Ada?
    ... When told that they would have to program in Ada, ... the government programming we do requires us to use Ada." ... When I was just a programmer, even a programming manager, before discovering ... I did not really understand software engineering very well. ...
    (comp.lang.ada)
  • Re: F-16 OFP written in C++?
    ... done far more non-Windows programming in C++ than I have Windows ... I have to wonder if OOP is a bad match for real-time military apps. ... suitablility of C++ over Ada for military apps, ...
    (rec.aviation.military)
  • Re: GNAT for MS Visual Studio
    ... I'm not talking about just a programming environment. ... Forms programs in the Ada Language!!! ... successful language in the Windows scheme of things. ...
    (comp.lang.ada)