comp.lang.ada
 help / color / mirror / Atom feed
From: cosc19z5@Bayou.UH.EDU (Spasmo)
Subject: Re: strongly typed langauge
Date: 1996/09/24
Date: 1996-09-24T00:00:00+00:00	[thread overview]
Message-ID: <527trk$vcn@Masala.CC.UH.EDU> (raw)


Hugh Bonney (hbonney@netcom.com) wrote:
: Reposting article removed by rogue canceller.

: Ian Ward (wardi@rsd.bel.alcatel.be) wrote:

[Snip]

: : Suppose I have two numbers

: : The first one is five, and it is the number of children, under ten
: : in England, who have behaved themselves at school since the 1976
: : decision by Strasbourg to ban corporal punishment in schools was
: : enforced.

: : The second number is 1200, this is the number of seconds it takes
: : to drink a pint of beer, say.

: : So we have two numbers, 1200 and 5, which we add together.

: : 1200 + 5 = 1205.

: : 1205 what, this clearly makes no sense...

:     Well, of course it does since the sum is well known to be a
:     physical constant. 

I think you are confused.  While it makes sense to add any given
number to another from a MATHEMATICAL view, it doesn't necessarily
make sense to add two numbers that represent different 
entities.  I mean adding school children to units of time
makes no sense whatsoever from the perspective of an application
and this is (what I believe) Ian was talking about.  Two
values, which while mathematically compatible, are incompatible
per the rules of your application, hence using strong typing
to guarantee that they remain so can keep you from goofing
up in new and exciting ways.


:     Another example might be to note that it's 2km from A to B,
:     300m from B to C, and 20mm from C to D. So if you walk from
:     A to D have you gone a distance of 322? In elementary school
:     we have to learn the essentials of data typing and one can 
:     start with that. It does make sense to add apples and oranges
:     sometimes, but it doesn't make sense to add km and mm even
:     if you want to know the distance from Paris to the end of
:     your nose.

It makes sense to add apples and oranges if the rules of your
application allow such an operation.  Someone brought up a
great example of a data type called FRUIT, of which apples
and oranges were instances (loose use of the term) of.
Adding apples to oranges in this context made sense since
the sum was that of fruit, and apples and oranges were both
fruit, ie: your application allowed such an operation.
However, if you didn't want to know the quantity of fruit
in general, but instead wanted to keep track of apples
and oranges SEPARATELY, then it makes no sense whatsoever
to add apples to oranges.  I mean what is the sum?  It has
no place in the application whatsoever.


[Snip]

:     Strong typing shouldn't be used as a substitute for thought
:     or care, where it's useful is in pointing out real difficulties
:     in either one person's thinking about a problem, or real
:     (and inevitable) differences in understanding from one person
:     to the next. One could have such a code inspection done by
:     an inspection program, of course, incorporating every type of
:     analysis that will execute by overnight, and going through all
:     the code in a project as well as pieces of it.

However it can and IMO should be used in conjunction with thought
and care, to enforce the categorizations which we make in our
programs, and also to catch errors.  Hey we all make errors,
and even with careful design bugs are liable to happen, so any
extra safety that comes my way is greatly appreciated (and used).

[Snip]

: : Ian Ward's opinions only : wardi@rsd.bel.alcatel.be

--
Spasmo
"John Wayne was a Nazi, he liked to play SS
 He had a picture of Adolph the Boy tucked in his cowboy vest"
	"John Wayne was a Nazi" by MDC





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

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

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