comp.lang.ada
 help / color / mirror / Atom feed
From: dsr@hector.UUCP (David S. Rosenblum)
Subject: Re: Collective response to := messages
Date: 9 Dec 88 03:15:24 GMT	[thread overview]
Message-ID: <10979@ulysses.homer.nj.att.com> (raw)
In-Reply-To: 772@marvin.cme.nbs.gov

In article <772@marvin.cme.nbs.gov> leake@cme.nbs.gov (Stephe Leake) writes:
>In article <10917@ulysses.homer.nj.att.com> dsr@hector.UUCP (David S. Rosenblum) writes:
>
>   As I argued in the case of assignment, overloading of type conversion is
>   overloading of a basic operation, and such a facility would allow
>   one to circumvent type checking.  As you suggested above, we don't want
>   to turn Ada into C.
>
>Type checking _cannot_ be circumvented by overloading of type
>conversion! Consider:
>
>type DEGREES is digits 6 range 0.0 .. 360.0;
>type RADIANS is digits 6;
>
>function DEGREES (Item : in RADIANS) return DEGREES
>is
>begin
>	return Item * 180.0 / PI;	-- range constraint is checked!
>end;
>
>Since the underlying Ada type checking is done on the function result,
>no circumvention of type checking is possible.

My comment did NOT have to do with checking the constraints of the
target type.  I hope anybody with a minimal familiarity with Ada knows
that type constraints are checked on function return values.  My point
was that overloading of type conversion will allow you to "covert" pointers
to integers, arrays to files, tasks to widgets, etc.  This is called "casting"
in C, better known as "anything goes".  To me such conversions are a
circumvention of Ada's strong typing model.

I'll try this just one more time.  By allowing the overloading of
basic operations, you may gain some flexibility in defining your
abstractions, but this gain will be achieved only at the (to me, unjustifiable)
cost of severely weakening Ada's strong typing strictures.  Any
proposal to increase flexibility in defining abstractions in Ada
MUST ("read my lips"--MUST) conform to the fundamental language philosophies
of Ada.

I would suggest two promising areas for making such improvements
in an "Ada-like" way.  (1) Allow user-specifiable initialization and
destruction routines for types.  Ray Trent and Bill Wolfe have been arguing
for a parameter passing semantics based on assignment.  Stroustrup, in his
C++ book, argues that you need initialization mechanisms, not assignment, for
parameter passing, and that initialization and assignment are
fundamentally different operations.  Initialization routines would
be appropriate for initializing parameters that are passed by copy, which
(at least for scalars) is the mandated parameter passing mechanism.
(2) Define a mechanism for allowing richer user-specified constraints
on types, e.g. "all objects of type EVEN must have even values", or "for
all objects of record type FOO, component BAR must always be greater than
component BAZ".  Then let Ada's inherent type checking mechanisms check
these constraints automatically.

In short, Ada has a very nice type checking framework.  We should try to
come up with proposals that improve that framework in ways that increases
its flexibility without decreasing its robustness; don't just propose tacking
on new language rules and band-aids that will cheaply rid you of your
frustrations with the current framework.


-------------------------------------------------------------------
David Rosenblum			UUCP: {ucbvax, decvax}!ulysses!dsr
AT&T Bell Laboratories		ARPA: dsr@ulysses.att.com
600 Mountain Ave.		      dsr%ulysses@att.arpa
Murray Hill, NJ 07974-2070
(201) 582-2906
-------------------------------------------------------------------

  reply	other threads:[~1988-12-09  3:15 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-11-28 22:19 Collective response to := messages Geoff Mendal
1988-11-29 14:39 ` Dennis Doubleday
1988-11-29 21:08 ` Ray Trent
1988-11-30 14:37   ` Stephe Leake
1988-12-01 14:54     ` David S. Rosenblum
1988-12-02 20:21       ` William Thomas Wolfe,2847,
1988-12-04 21:15         ` David S. Rosenblum
1988-12-04 23:27           ` William Thomas Wolfe,2847,
1988-12-05 14:46             ` David S. Rosenblum
1988-12-05 21:23               ` William Thomas Wolfe,2847,
1988-12-07 17:33                 ` Stephe Leake
1988-12-07 16:03               ` Definition of pass by reference Robert Eachus
1988-12-07 17:15             ` Collective response to := messages Stephe Leake
1988-12-07 16:07       ` Stephe Leake
1988-12-09  3:15         ` David S. Rosenblum [this message]
1988-12-01 21:31     ` Ray Trent
1988-12-07 16:21       ` Stephe Leake
1988-11-30 16:29   ` David S. Rosenblum
1988-11-30 18:29     ` William Thomas Wolfe,2847,
1988-11-30 22:28       ` David S. Rosenblum
1988-12-01  3:09         ` William Thomas Wolfe,2847,
1988-12-01 15:16           ` David S. Rosenblum
1988-12-02 19:31             ` William Thomas Wolfe,2847,
1988-12-04 21:03               ` David S. Rosenblum
1988-12-05  2:34                 ` William Thomas Wolfe,2847,
1988-12-05 14:07                   ` David S. Rosenblum
1988-12-07 17:26                     ` Stephe Leake
1988-12-06 19:16                 ` Collective response to := messa stt
1988-12-09  3:39                   ` David S. Rosenblum
1988-11-30 19:13     ` CORRECTION Re: Collective response to := messages David S. Rosenblum
1988-12-01 18:31     ` Ray Trent
1988-12-02 14:49       ` David S. Rosenblum
1988-12-05 17:33         ` Collective response to := messa stt
1988-11-30 18:24   ` Collective response to := messages Robert Eachus
1988-12-02 14:58     ` David S. Rosenblum
1988-12-02 19:34   ` Mark C. Adolph
1988-12-05 17:15     ` Collective response to := messa stt
1988-11-29 21:44 ` Collective response to := messages William Thomas Wolfe,2847,
  -- strict thread matches above, loose matches on Subject: below --
1989-07-26 20:34 Memory Access Question tony
1989-07-27 13:06 ` richard a hammond
1989-07-27 18:53   ` Ray Trent
1989-07-28  0:48     ` Mike Murphy
1989-08-02 13:23       ` Mike Walsh
1989-08-02 20:20         ` Mike Murphy
1989-07-29  0:00 ` Brian Sullivan
1988-12-05  6:53 Collective response to := messages Erland Sommarskog
1988-12-03 22:53 Erland Sommarskog
1988-12-04 20:41 ` William Thomas Wolfe,2847,
1988-12-05  5:47   ` Richard A. O'Keefe
1988-12-05 12:45     ` William Thomas Wolfe,2847,
1988-12-06  1:54       ` Richard A. O'Keefe
1988-12-06 20:43         ` William Thomas Wolfe,2847,
1988-12-03 21:08 Erland Sommarskog
1988-12-04 20:30 ` William Thomas Wolfe,2847,
1988-11-14 13:20 Ada language revision Stanley Roger Allen, AdaDude
1988-11-15 23:28 ` Wilmer Rivers
1988-11-16 19:06   ` William Thomas Wolfe,2847,
1988-11-17 15:34     ` Stephe Leake
1988-11-18 16:39       ` Steve Tynor
1988-11-18 19:22       ` Ron Guilmette
1988-11-23 22:22       ` William Thomas Wolfe,2847,
1988-11-29 15:35         ` Stephe Leake
1988-11-18  0:32     ` Ron Guilmette
1988-11-22 14:37       ` Stephe Leake
1988-11-23 13:37         ` Dennis Doubleday
1988-11-23 19:41           ` Steve Tynor
1988-11-23 21:14             ` Richard Pattis
1988-11-25 20:36             ` Robert Firth
1988-11-29 15:12           ` limited private types Stephe Leake
1988-12-01 23:06             ` Ron Guilmette
1988-12-05  1:48               ` Paul Stachour
1988-12-05 12:31                 ` Reference Semantics William Thomas Wolfe,2847,
1988-12-06  0:29                   ` Paul Stachour
1988-12-07  1:07                     ` Reference Semantics, assignment overloading, etc Ray Trent
1988-12-08 17:36                       ` Reference Semantics, assignment ryer
1988-12-06 16:56               ` limited private types ryer
1988-12-06 20:09               ` stt
1988-12-07 15:51               ` Stephe Leake
1988-11-21 15:40   ` Ada language revision stt
replies disabled

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