comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com (Ted Dennison)
Subject: Re: How to delete charcters in a string?
Date: 1 Feb 2002 07:59:39 -0800
Date: 2002-02-01T15:59:40+00:00	[thread overview]
Message-ID: <4519e058.0202010759.43b26a19@posting.google.com> (raw)
In-Reply-To: 3C596BE4.D0F1BFCB@otelco.net

Larry Hazel <lhhazel@otelco.net> wrote in message news:<3C596BE4.D0F1BFCB@otelco.net>...
> Good points Ted.  It caused me to wonder.  Since a null character in Ada means
> (essentially) "no character here", rather than end of string, could you just
> replace the character you want to delete with a null character?

If it truly means that. If you are writing the program that will
process the string, then you can certinaly make it mean that. But that
doesn't mean that
"Foo" & ASCII.NUL = "Foo"
will return true. So they are *not* the same in that sense. How a
device (like a terminal display) will handle a nul is up to it.

That's not the point though. Since C's strings are somewhat dynamic,
using them as storage while the contents are massaged into proper
place is encouraged. Thus algorithms that cause string values to be
modified are fairly natural in C. In Ada its usualy much more sensible
(and possible) to figure our your string's final value in one shot. If
you need intermediate steps, you'd usually want to use intermediate
strings. So algorithms that rely on mucking with string values in
place are discouraged.

My point is that one shouldn't try solving problems the C way in Ada.
As they say at NASA, "Never apply a Star Trek solution to a Babylon 5
problem". Newbies are quite likely to fall into such a trap, and I
haven't seen this one give his rationale for needing  a "delete one
character" solution so that I can believe otherwise. So the first
answer here shouldn't be "here's how you do that...", it should be
"Why do you need to do that?"

-- 
T.E.D.
Home     -  mailto:dennison@telepath.com (Yahoo: Ted_Dennison)
Homepage -  http://www.telepath.com/dennison/Ted/TED.html



  reply	other threads:[~2002-02-01 15:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-30  0:25 How to delete charcters in a string? Anthony Wise
2002-01-30  2:44 ` Steve Doiel
2002-01-30  3:22 ` dale
2002-01-30  6:37   ` tmoran
2002-01-30  7:49     ` Dale Stanbrough
2002-01-30 15:04       ` Marin David Condic
2002-01-30 11:21 ` Preben Randhol
2002-01-30 15:15   ` Marin David Condic
2002-01-31 14:47 ` Ted Dennison
2002-01-31 16:08   ` Larry Hazel
2002-02-01 15:59     ` Ted Dennison [this message]
2002-02-01 17:05     ` Darren New
2002-02-01  6:14   ` tmoran
2002-02-01 15:56     ` Stephen Leake
2002-02-01 17:53       ` Pascal Obry
2002-02-18  3:48         ` David Thompson
2002-02-18 19:44           ` Stephen Leake
     [not found] <F207EAsx2Pwf500RR1h00019d09@hotmail.com>
2002-01-30  1:16 ` Eric Merritt
2002-01-30  1:16 ` Eric Merritt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox