comp.lang.ada
 help / color / mirror / Atom feed
From: mab@dst17.wdl.loral.com (Mark A Biggar)
Subject: Re: Generic association example (was Re: Mutual Recursion Challenge)
Date: Thu, 27 Oct 1994 14:37:54 GMT
Date: 1994-10-27T14:37:54+00:00	[thread overview]
Message-ID: <1994Oct27.143754.27957@wdl.loral.com> (raw)
In-Reply-To: 1994Oct26.232154.29094@swlvx2.msd.ray.com

In article <1994Oct26.232154.29094@swlvx2.msd.ray.com> jgv@swl.msd.ray.com (John Volan) writes:
>But I still see a problem: It looks like each class is giving up the
>ability to use static strong typing to assert the exact type of the
>*other* objects associated with it.  In other words, a "Person-who-
>can-occupy-an-Office" can't assert that it's associated with an
>"Office-that-can-be-occupied-by-a-Person" (or with a "Total Office",
>for that matter).  All it can say is that it's associated with an
>"Office".  So when a client asks a Person object for its Office, the
>Person can answer with its associated "Office", but it can't provide
>the client with a "Total" view of that Office.  The client would have
>to do the view-conversion itself by "narrowing" (safely downcasting)
>that Office into a "Total Office".
>
>That narrowing operation would incur a run-time check on the Office's
>tag.  But that check is actually redundant.  You know and I know that
>the Office object will really be a "Total Office"; we can assert that
>as a statically-determined fact, since we're the designers of the
>software, and that was our original intent for the association.
>However, when we go to write our Ada code for the Person class, we
>discover that we can't explicitly assert, in the Ada code itself, that
>a Person's associated Office will actually be one of those "Total
>Offices".  So we can't tell the compiler that this is a
>statically-determined assertion that it can check statically.
>Instead, it becomes a dynamically-checked assertion.  In short, this
>takes us a step away from a statically-checked style of programming,
>and moves us closer to the dynamically-checked style of languages such
>as Smalltalk.
>
>I suppose we could apply a pragma Suppress at some point to eliminate
>the extra dynamic check, once the program was fully tested.  But, more
>to the point, we've lost a certain amount of expressibility.  Since
>the Ada code doesn't directly express what we mean, its readability by
>other Ada programmers (for example, maintainers) is reduced.  

Actually this case is not a real problem, as a smart compiler can optimize
the run time check away.  Any "Narrowing" downcasting from an abstract
type to its first non-abstract decendent will always pass the check, and
so the check need not be done, even without the pragma Suppress.

--
Mark Biggar
mab@wdl.loral.com




  parent reply	other threads:[~1994-10-27 14:37 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-10-12 22:49 SOLVED! Decoupled Mutual Recursion Challenger John Volan
1994-10-17 15:48 ` John Volan
1994-10-17 17:55   ` Bob Duff
1994-10-17 20:52     ` John Volan
1994-10-17 22:10       ` Bob Duff
1994-10-18 22:17         ` John Volan
1994-10-19  1:01           ` Bob Duff
1994-10-19  4:45             ` Jay Martin
1994-10-19 14:38               ` Mark A Biggar
     [not found]                 ` <38fi4r$l81@oahu.cs.ucla.edu>
1994-10-24 11:49                   ` Mutual Recursion Challenge Robert I. Eachus
1994-10-24 20:32                     ` John Volan
1994-10-26 11:42                       ` Generic association example (was Re: Mutual Recursion Challenge) Robert I. Eachus
1994-10-26 23:21                         ` John Volan
1994-10-27 10:53                           ` Robert I. Eachus
1994-10-31 17:34                             ` John Volan
1994-10-27 14:37                           ` Mark A Biggar [this message]
1994-10-24 17:42                   ` SOLVED! Decoupled Mutual Recursion Challenger John Volan
1994-10-24 22:37                     ` Jay Martin
1994-10-25  5:47                       ` Matt Kennel
1994-10-25 10:04                         ` David Emery
1994-10-25 16:43                         ` John Volan
1994-10-27  4:25                           ` Rob Heyes
1994-10-28  9:03                             ` Mutual Recursion (was Re: SOLVED! Decoupled Mutual Recursion Challenger) Robert I. Eachus
1994-10-28 15:04                             ` SOLVED! Decoupled Mutual Recursion Challenger Robb Nebbe
1994-10-25 15:54                       ` John Volan
1994-10-26  1:24                         ` Bob Duff
1994-10-28  4:28                         ` Jay Martin
1994-10-28 10:52                           ` Robert I. Eachus
1994-10-28 18:46                             ` Jay Martin
1994-11-02 14:56                               ` Robert I. Eachus
1994-10-29  0:38                           ` Bob Duff
1994-10-29  7:26                             ` Jay Martin
1994-10-29 11:59                             ` Richard Kenner
1994-10-31 13:17                               ` Robert Dewar
1994-10-31 14:13                               ` gcc distribution (was: SOLVED! Decoupled Mutual Recursion Challenger) Norman H. Cohen
1994-11-02 14:14                                 ` Richard Kenner
1994-11-04 23:56                                   ` Michael Feldman
1994-10-31 18:44                           ` SOLVED! Decoupled Mutual Recursion Challenger John Volan
1994-10-20 11:25               ` Robb Nebbe
1994-10-20 19:19                 ` John Volan
1994-10-26  0:07                 ` Mark S. Hathaway
1994-10-26 18:48                 ` gamache
1994-10-27  2:15                   ` John Volan
     [not found]           ` <CxwGJF.FwB@ois.com>
1994-10-19 16:35             ` John Volan
1994-10-17 22:54   ` Cyrille Comar
replies disabled

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