comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Equality operator overloading in ADA 83
Date: 1997/05/05
Date: 1997-05-05T00:00:00+00:00	[thread overview]
Message-ID: <E9ppwJ.EHv@world.std.com> (raw)
In-Reply-To: dewar.862718892@merv


In article <dewar.862718892@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
>But in general we follow the rule in Ada of not using the others clause
>precisely because it disables an important check.

I follow a rule more like this: Use "others" only if you want that
alternative to cover all possibilities not mentioned, INCLUDING THOSE
POSSIBILITIES THAT HAVEN'T BEEN INVENTED YET.  E.g. for an enumeration
type, others should conceptually include all the enumeration literals
that somebody might add to the program in some future version.

Yes, this implies that "others" is *usually* not a good idea.  But it
sometimes is a good idea.  For example, a lexical analyzer for Ada might
have a case_statement on characters to do something in particular for
the cases mentioned in the RM as legal tokens, and have a "when others
=> Error;" alternative.  There's really no particular value in listing
all the error-characters explicitly.

(I use the same rule for "others" in an array aggregate.  For record
aggregates, I can't remember ever using "others" -- it's not clear to me
why it's even allowed.)

>... A case statement that
>requires an others is entirely equivalent to a set of elsif's, so why
>have an alternative syntax.

I don't think they're equivalent.  With a case statement (with others)
you still know that the alternatives are mutually exclusive, and that
their evaluation has no dependence on the current state of global
variables.  You know that all the alternatives are testing against a
single value, and you know that expression is evaluated exactly once
(e.g. consider translating "case F(X) is ..." into elsif's).  You know
that the order of the alternatives doesn't matter.  You know these
things as soon as you see "case" -- with elsif's, you have to examine
each condition carefully to gather such information.  Using "others"
does not damage all of these good things, and knowing these things
easily is helpful in reading a program.  If I were extending the
case_statement, I would try to retain these properties.

- Bob




  reply	other threads:[~1997-05-05  0:00 UTC|newest]

Thread overview: 114+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-21  0:00 Equality operator overloading in ADA 83 Manuel Wenger
1997-04-22  0:00 ` Matthew Heaney
1997-04-22  0:00   ` Philip Brashear
1997-04-22  0:00   ` Mats Weber
1997-04-22  0:00     ` Matthew Heaney
1997-04-23  0:00       ` Mats Weber
1997-04-23  0:00         ` Robert A Duff
1997-04-25  0:00           ` Kevin Cline
1997-04-25  0:00             ` Robert A Duff
1997-04-25  0:00             ` Matthew Heaney
1997-04-25  0:00               ` Robert A Duff
1997-04-25  0:00                 ` Jon S Anthony
1997-04-27  0:00                   ` Robert Dewar
1997-04-28  0:00                   ` Robert I. Eachus
1997-04-29  0:00                     ` Jon S Anthony
1997-04-26  0:00               ` Robert Dewar
1997-04-27  0:00                 ` Matthew Heaney
1997-04-27  0:00                   ` Robert A Duff
1997-04-26  0:00             ` Robert Dewar
1997-04-26  0:00               ` Matthew Heaney
1997-04-22  0:00     ` Robert A Duff
1997-04-22  0:00       ` Mats Weber
1997-04-22  0:00       ` Matthew Heaney
1997-04-23  0:00         ` Mats Weber
1997-04-23  0:00           ` Robert A Duff
1997-04-24  0:00             ` Mats Weber
1997-04-24  0:00               ` Robert A Duff
1997-04-24  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Robert A Duff
1997-04-26  0:00                     ` Nick Roberts
1997-04-26  0:00                       ` Robert A Duff
1997-04-26  0:00                         ` Robert Dewar
1997-04-27  0:00                           ` Robert A Duff
1997-04-26  0:00                             ` Robert Dewar
1997-04-28  0:00                               ` Simon Wright
1997-04-29  0:00                                 ` Robert I. Eachus
1997-04-26  0:00                       ` Robert Dewar
1997-04-26  0:00                         ` Matthew Heaney
1997-05-02  0:00                           ` Nick Roberts
1997-05-04  0:00                             ` Robert Dewar
1997-05-05  0:00                               ` Robert A Duff [this message]
1997-05-05  0:00                               ` Mats Weber
1997-05-05  0:00                                 ` Robert Dewar
1997-05-06  0:00                                   ` Matthew Heaney
1997-05-06  0:00                                     ` Robert Dewar
1997-05-07  0:00                                     ` Tucker Taft
1997-04-29  0:00                       ` Mats Weber
1997-05-01  0:00                         ` Robert Dewar
     [not found]                           ` <01bc571c$01f3ffc0$5de2b8cd@p5120.bda>
1997-05-03  0:00                             ` Robert Dewar
1997-04-27  0:00                     ` Robert Dewar
1997-04-27  0:00                       ` Fergus Henderson
1997-04-27  0:00                         ` Robert Dewar
1997-04-28  0:00                           ` Fergus Henderson
1997-04-28  0:00                             ` Robert Dewar
1997-04-25  0:00                 ` Mats Weber
1997-04-25  0:00                 ` Kevin Cline
1997-04-25  0:00                   ` Robert A Duff
1997-04-25  0:00                   ` Mats Weber
1997-04-25  0:00                     ` Robert Dewar
1997-04-29  0:00                       ` Mats Weber
1997-05-01  0:00                         ` Robert Dewar
1997-04-25  0:00                   ` Mats Weber
1997-04-27  0:00                     ` Robert Dewar
1997-04-29  0:00                       ` Mats Weber
1997-04-27  0:00                 ` Geert Bosch
1997-04-24  0:00               ` Matthew Heaney
1997-04-25  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Matthew Heaney
1997-04-26  0:00                     ` Robert Dewar
1997-04-26  0:00                   ` Fergus Henderson
1997-04-26  0:00                     ` Robert A Duff
1997-04-26  0:00                       ` Robert Dewar
1997-04-27  0:00                     ` Robert Dewar
1997-04-25  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Matthew Heaney
1997-04-26  0:00                     ` Robert Dewar
1997-04-26  0:00                     ` Robert A Duff
1997-04-28  0:00               ` Robert Dewar
1997-04-28  0:00               ` Robert Dewar
1997-04-29  0:00                 ` Matthew Heaney
1997-05-01  0:00                   ` Robert Dewar
1997-04-29  0:00                 ` Mats Weber
1997-04-29  0:00                   ` Robert A Duff
1997-04-29  0:00                     ` Matthew Heaney
1997-05-02  0:00                       ` Tucker Taft
1997-05-02  0:00                         ` Robert Dewar
1997-05-02  0:00                           ` Robert A Duff
1997-05-03  0:00                             ` Robert Dewar
1997-05-01  0:00                   ` Robert Dewar
1997-04-23  0:00           ` Robert Dewar
1997-04-24  0:00             ` Robert A Duff
1997-04-29  0:00             ` Mats Weber
1997-05-01  0:00               ` Robert Dewar
1997-04-24  0:00         ` Robert Dewar
1997-04-24  0:00     ` Robert Dewar
1997-04-24  0:00       ` Robert A Duff
1997-04-25  0:00         ` Robert Dewar
1997-04-25  0:00           ` Matthew Heaney
1997-04-26  0:00             ` Robert Dewar
1997-04-26  0:00               ` Robert A Duff
1997-04-26  0:00                 ` Robert Dewar
1997-04-26  0:00                   ` Matthew Heaney
1997-04-27  0:00                   ` Robert A Duff
1997-04-26  0:00                 ` Robert Dewar
1997-04-26  0:00                   ` Matthew Heaney
1997-04-27  0:00                     ` Robert Dewar
1997-04-27  0:00                   ` Robert A Duff
1997-04-26  0:00                     ` Robert Dewar
1997-05-02  0:00                       ` Nick Roberts
1997-05-04  0:00                         ` Robert Dewar
1997-04-22  0:00 ` Kevin Cline
1997-04-22  0:00   ` Mark A Biggar
1997-04-24  0:00   ` Keith Thompson
1997-04-22  0:00 ` Mats Weber
replies disabled

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