comp.lang.ada
 help / color / mirror / Atom feed
From: Alan Brain <aebrain@dynamite.com.au>
Subject: Re: strongly typed langauge
Date: 1996/09/20
Date: 1996-09-20T00:00:00+00:00	[thread overview]
Message-ID: <3242665A.76FD@dynamite.com.au> (raw)
In-Reply-To: 51rai1$2jh@rc1.vub.ac.be


AGBOH CHARLES wrote:

> Hi
 
> Could Some explain to me what the term "strongly typed language" is in the
> context of ada.  Could you give some examples and tips as on how to
> avoid errors related to this particular domain.

Geen Problem, Pas de Probleme

OK, this is best answered by an example.
Suppose you had a quantity of 5 apples and 11 oranges.

In an untyped language, you could add 07 and 0B (Hex) to make 10 (Hex)
In a weakly typed language, you could declare them both as Integer
quantities, and add 5 to 11 to get 16 - but 16 of what?
In a strongly typed language, unless you'd made a new type, FRUIT_TYPE,
and defined that apples and oranges were both subtypes of this base
type,
the compiler would reject a statement adding apples to oranges, as they
are two different types.

Similarly, suppose you knew that the number of apples had to be within
the range 0 to 47. A strongly typed language would allow you to express
this, as 

subtype NUMBER_OF_APPLES_TYPE is INTEGER range 0..47;

and any operation which resulted in a quantity >47 or <0 would cause a
failure to be detected. 

Tot Ziens/A Bientot 

----------------------      <> <>    How doth the little Crocodile
| Alan & Carmel Brain|      xxxxx       Improve his shining tail?
| Canberra Australia |  xxxxxHxHxxxxxx _MMMMMMMMM_MMMMMMMMM
---------------------- o OO*O^^^^O*OO o oo     oo oo     oo  
                    By pulling Maerklin Wagons, in 1/220 Scale




  parent reply	other threads:[~1996-09-20  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-19  0:00 strongly typed langauge AGBOH CHARLES
1996-09-19  0:00 ` Larry Kilgallen
1996-09-19  0:00 ` Ian Ward
1996-09-22  0:00   ` Hugh Bonney
1996-09-23  0:00     ` Alan Brain
1996-09-22  0:00   ` Hugh Bonney
1996-09-20  0:00 ` Alan Brain [this message]
1996-09-23  0:00   ` Robin Vowels
  -- strict thread matches above, loose matches on Subject: below --
1996-09-21  0:00 Spasmo
1996-09-24  0:00 Spasmo
replies disabled

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