comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: Time to join the fold?
Date: 1999/01/25
Date: 1999-01-25T00:00:00+00:00	[thread overview]
Message-ID: <78iq2m$br9$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 78i8s4$hth$1@its.hooked.net

In article <78i8s4$hth$1@its.hooked.net>,
  "Mike Silva" <mjsilva@jps.net> wrote:

> Now for another question.  Some people have mentioned getting into the Ada
> "mind-set".  What are the main components of this mind-set?  What, IOW,
> should I pay special attention to in order to avoid simply writing "C in
> Ada" (whatever that might mean).  Thanks again for the help.

For the most part, that's just something you'll have to work out. (Is there a
support group for recovering C coders?)

One good example that does spring to mind is string handling. C coders want
to be able to assign a length 5 string into a length 12 string because strcpy
would do that for them. So their first try tends to be:  Str : String(1..12);
begin  Str := "hiho!";

Which won't work in Ada because the two arrays aren't the same size. Then
they will try using a loop or slice to assign the 5 characters only. Then
they try to print the twelve character string. This won't do what they want,
because Ada strings aren't null terminated. Then they discover that they have
to instantiate a generic routine to ouput a number as a string, and they are
liable to get insanely frustrated.

The problem is that the approach is all wrong. Ada developers tend to handle
strings as literals or constants whenever possible. The '&' operator on
strings makes this much easier to deal with. Scalar numbers can be converted
to strings inline w/ "'image". In a severe jam a declare block can be used to
get a localized constant string, or one of the ada.strings packages can be
used.

This is just one example of many. I guess the main point is that you have to
think in terms of the tools at your disposal, not in terms of the tools you
*don't* have.

T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  reply	other threads:[~1999-01-25  0:00 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-22  0:00 Time to join the fold? Mike Silva
1999-01-22  0:00 ` Tucker Taft
1999-01-25  0:00   ` Mike Silva
1999-01-25  0:00     ` dennison [this message]
1999-01-31  0:00       ` Matthew Heaney
1999-02-01  0:00         ` Dynamicly declaring arrays (was: Time to join the fold?) dennison
1999-02-01  0:00           ` Larry Kilgallen
1999-02-01  0:00           ` Matthew Heaney
1999-02-02  0:00           ` robert_dewar
1999-02-02  0:00             ` news.oxy.com
1999-02-02  0:00               ` dennison
1999-02-02  0:00               ` nabbasi
1999-02-02  0:00                 ` dennison
1999-02-02  0:00                   ` robert_dewar
1999-02-02  0:00                     ` William Clodius
1999-02-03  0:00                       ` Robert A Duff
1999-02-03  0:00                         ` Modula 2 William Clodius
1999-02-02  0:00                     ` Dynamicly declaring arrays (was: Time to join the fold?) Al Christians
1999-02-02  0:00                     ` dennison
1999-02-02  0:00               ` robert_dewar
1999-02-03  0:00                 ` news.oxy.com
1999-02-03  0:00                   ` Robert I. Eachus
1999-02-04  0:00                   ` M2 history - relations to Ada news.oxy.com
1999-02-04  0:00                     ` robert_dewar
1999-02-04  0:00                     ` Chuck Clark
1999-02-10  0:00                       ` Andreas Borchert
1999-02-04  0:00                     ` David C. Hoos, Sr.
1999-02-04  0:00                       ` news.oxy.com
1999-02-04  0:00                         ` G.S. Vigneault
1999-02-04  0:00                         ` Jean-Pierre Rosen
1999-02-04  0:00                       ` Aron Felix Gurski
1999-02-05  0:00                         ` Robert Lanziner-Furtenbach
1999-02-04  0:00                           ` David C. Hoos, Sr.
1999-02-05  0:00                           ` Robert Lanziner-Furtenbach
1999-02-04  0:00                       ` Chris Morgan
1999-02-04  0:00                         ` Jerry van Dijk
1999-02-05  0:00                         ` Grant Edwards
1999-01-25  0:00     ` Time to join the fold? Pat Rogers
1999-01-25  0:00     ` robert_dewar
1999-02-02  0:00       ` news.oxy.com
1999-01-26  0:00     ` Jean-Pierre Rosen
1999-01-26  0:00       ` dennison
1999-01-26  0:00         ` Pascal MALAISE
1999-01-27  0:00     ` Steve Whalen
1999-02-01  0:00       ` Robert I. Eachus
1999-01-23  0:00 ` Matthew Heaney
1999-01-23  0:00   ` Tom Moran
1999-01-23  0:00 ` Steve Whalen
1999-01-23  0:00   ` Tom Moran
1999-01-24  0:00     ` Steve Whalen
1999-01-24  0:00       ` Tom Moran
1999-01-24  0:00 ` Larry Kilgallen
replies disabled

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