comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff Carter <jrcarter@acm.org>
Subject: Re: constant string array
Date: Tue, 12 Dec 2000 04:56:30 GMT
Date: 2000-12-12T04:56:30+00:00	[thread overview]
Message-ID: <3A35AFFF.CA2BA2F9@acm.org> (raw)
In-Reply-To: 912ut9$fga$1@nnrp1.deja.com

Robert Dewar wrote:
> There is a conceptual difference between using a boolean
> expression in a test, and using it as a general value (indeed
> it is this conceptual difference that leads ABC to allow
> "boolean" expressions ONLY in the context of a test.

ABC?

> I think the argument is even stronger in comparing:
> 
>    a := b > c;
> 
> with
> 
>    if b > c then
>       a := true;
>    else
>       a := false;
>    end if;
> 
> I always used to criticize students for the spelled out version
> giving the canonical advice to replace it with the use of a
> boolean expression. But in fact I think the spelled out version
> is often clearer in its intent.
> 
> You can get some feeling for this by supposing that someone
> looking at the above code decides to replace
> 
>    A : boolean;
> 
> by
> 
>    type motor_status is (on, off);
>    a : motor_status;
> 
> with a revision history saying
> 
>    use ON/OFF for motor status instead of True/False, makes
>    code clearer.

Hopefully your style checker will flag your inconsistent capitalization.

Obviously, I disagree with your premise. In all of your examples I find
the use of a Boolean expression as a value clearer than the version with
an if. If the type of a variable changes, you should expect to have to
make changes everywhere it is used. I certainly expect some of those
changes to be non-trivial.

What is important is to use a language that flags any places where the
use of the variable has been missed, rather than one that silently
compiles the meaningless code.

I have found that this kind of construct generally indicates a lack of
understanding of Booleans, frequently from people with experience with
languages that do not have a Boolean type. Such people frequently do
other irritating things, like putting unnecessary parentheses around the
condition of an if, and forgetting the "then". Learning that Boolean is
a type like any other enumeration type, and its values no different than
any other enumeration type, is often a major step in grasping the Ada
mind set.

-- 
Jeff Carter
"I blow my nose on you."
Monty Python & the Holy Grail



  parent reply	other threads:[~2000-12-12  4:56 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <910u3p$v9j$1@nnrp1.deja.com>
     [not found] ` <slrn9383g6.coa.randhol+abuse@kiuk0156.chembio.ntnu.no>
     [not found]   ` <9138e5$o6a$1@nnrp1.deja.com>
2000-12-11 19:34     ` constant string array Robert Dewar
2000-12-11 21:41 ` Pascal Obry
2000-12-12  2:54   ` Robert Dewar
2000-12-12  2:56   ` Robert Dewar
     [not found] ` <3A3445A8.8FC404D5@acm.org>
     [not found]   ` <912ut9$fga$1@nnrp1.deja.com>
     [not found]     ` <9132ng$j10$1@nnrp1.deja.com>
2000-12-11 19:39       ` Robert Dewar
2000-12-12  2:31     ` Ken Garlington
2000-12-12  2:53       ` Robert Dewar
2000-12-12  4:39         ` Ken Garlington
2000-12-12  4:56     ` Jeff Carter [this message]
2000-12-12 20:57       ` Beard, Frank
2000-12-12 23:05         ` Jeff Carter
2000-12-13  0:37           ` Robert Dewar
2000-12-13  0:36         ` Robert Dewar
2000-12-13  0:39         ` Robert Dewar
2000-12-13  2:02           ` Beard, Frank
2000-12-13  2:33             ` Robert Dewar
2000-12-13  2:55               ` Beard, Frank
2000-12-13  4:00                 ` Ken Garlington
2000-12-13 13:38                   ` Bad coding standards Marc A. Criley
2000-12-13 13:54                     ` Ken Garlington
2000-12-13 20:55                     ` David Emery
2000-12-14 13:07                       ` Robert Dewar
2000-12-14 14:21                         ` Ken Garlington
2000-12-15  0:08                           ` Wayne Magor
2000-12-15  1:40                             ` Ken Garlington
2000-12-15  3:18                         ` DuckE
2000-12-15  4:45                           ` Ed Falis
2000-12-15 15:44                           ` Robert C. Leif, Ph.D.
2000-12-15 16:34                             ` Ted Dennison
2000-12-16  6:08                               ` Robert C. Leif, Ph.D.
2000-12-16  1:16                             ` Robert Dewar
2000-12-16  1:19                             ` Robert Dewar
2000-12-17  5:49                               ` Robert C. Leif, Ph.D.
2000-12-17  8:24                                 ` Robert Dewar
2000-12-15 15:56                       ` Charles H. Sampson
2000-12-15 20:43                         ` Wayne Lydecker
2000-12-16  4:31                           ` Ken Garlington
2000-12-16 11:36                           ` Robert Dewar
2000-12-15 21:36                         ` tmoran
2000-12-15 18:41 ` constant string array Freelancer
replies disabled

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