comp.lang.ada
 help / color / mirror / Atom feed
From: O'Connor <oconnor@apci.net>
Subject: Re: next "big" language?? (disagree)
Date: 1996/06/08
Date: 1996-06-08T00:00:00+00:00	[thread overview]
Message-ID: <31B9B514.37A3@apci.net> (raw)
In-Reply-To: Pine.GSO.3.92.960607093652.23839A-100000@nunic.nu.edu


Richard Riehle wrote:
> 
> On Thu, 6 Jun 1996, Richard Riehle wrote:
> 
> To Anyone who might have noticed:
> 
> I guess I should desk-check my code more carefully.  The example shown
> below would generate a compile-time error due to a type mismatch. Better
> to have defined the index type as a subtype of Positive, or even Integer
> than a a distinct type.  This points out one of the benefits of Ada:
> when sloppy coders, such as I seem to be, make this kind of error, it
> is easily detected and rejected by the compiler.
> 
> Sorry for the coding error. Mea culpa. The offending code follows:
> 
> Richard Riehle

But is this truly an 'error' in that your code does not express your 
requirements?  The problem isn't with what your are trying to accomplish. 
 The problem is that you have violated the language's rules for how to 
express a particular idea.  As such, the compiler has merely enforced the 
language rules.  Any decent compiler for any language will enforce the 
rules for that language.

  As a personal opinion, I think the Ada typing rules caused you to make 
the error in the first place that you compliment the compiler for 
catching.

> 
> >      type T1 is range 1..10;
> 
>        -- change the preceding to
>        subtype T1 is Positive range 1..10;
> 


If I was doing this in Smalltalk I could do it a number of ways; 
depending on why I was trying to constrain it.  
	For example, if I just needed a generic concept of an contrained 
range Integer, I would probably subclass Integer and added supporting 
instance variables and methods.  The limits on the new class would be 
either instance variables to allow each object to have individual limits, 
or class variables to enforce common limits across all objects of the 
class.  The attraction of the class limit approach would be that I could 
use Class methods to accomplish the various range looping mechanisms.
	If instead I had some Domain Object (a Bank Account) whose 
attributes had domain contraints against their values; I would probably 
write range checking code into the various get and set methods.  If I 
wanted a more dynamic solution, I would probably use some sort of 
Validator class.  One interesting idea is that fact that the contraints 
agianst the values of an attribute are contingent on the values in other 
attributes in the object, or other objects.  "X must be between 1 and 5 
if Y is less then 7, otherwise X must be between 4 and 12."  Expressing 
such rules is not as straightforward using a simple subtyping approach.  
Another twist is the idea of using a database table to express the 
Metadata (including constraints) associated with a particular attribute. 
 The database could hold the limits in values; A Validator object could 
load these limits when the program started.  Changing these limits based 
on new business conditions could be accomplished with a database update 
and no code changes at all.

	Anyway, just some meandering food for thought....

James O'Connor
oconnor@apci.net
-- 
          ##
         ##
  ########	 "He that loveth not
 ########		 knoweth not God."
     ##			--1 John 4:8
    ##
   ##
  ##
 ##




  reply	other threads:[~1996-06-08  0:00 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4p0fdd$4ml@news.atlantic.net>
1996-06-04  0:00 ` next "big" language?? (disagree) Peter Hermann
1996-06-04  0:00   ` The Amorphous Mass
1996-06-04  0:00     ` Peter Hermann
1996-06-04  0:00       ` The Amorphous Mass
1996-06-05  0:00         ` Michael David WINIKOFF
1996-06-07  0:00           ` Robert Dewar
1996-06-04  0:00     ` Robert Dewar
1996-06-06  0:00       ` Ken Garlington
1996-06-12  0:00       ` Help making ada pretty CSC Trusted Systems Group
1996-06-14  0:00         ` Sandy McPherson
1996-06-19  0:00         ` Ruediger Berlich
1996-06-05  0:00     ` next "big" language?? (disagree) Ian Ward
1996-06-05  0:00       ` The Amorphous Mass
1996-06-08  0:00         ` Robert Dewar
1996-06-08  0:00           ` The Amorphous Mass
1996-06-09  0:00             ` Robert Dewar
1996-06-08  0:00         ` Robert Dewar
1996-06-05  0:00   ` ++           robin
1996-06-05  0:00     ` Ian Ward
1996-06-05  0:00       ` Ian Ward
1996-06-06  0:00         ` Richard Riehle
1996-06-07  0:00           ` Richard Riehle
1996-06-08  0:00             ` O'Connor [this message]
1996-06-07  0:00           ` Robert Dewar
1996-06-10  0:00             ` Richard Riehle
1996-06-11  0:00           ` ++           robin
1996-06-11  0:00             ` James_Rogers
1996-06-11  0:00               ` Kevin J. Weise
1996-06-11  0:00             ` David Weller
1996-06-11  0:00             ` Chris Warack <sys mgr>
1996-06-11  0:00         ` ++           robin
1996-06-11  0:00           ` Ian Ward
1996-06-12  0:00             ` ++           robin
1996-06-12  0:00               ` Ian Ward
1996-06-11  0:00       ` Jon S Anthony
     [not found]   ` <4p60nk$imd@euas20.eua.ericsson.se>
     [not found]     ` <4p8lmq$oq7@goanna.cs.rmit.edu.au>
1996-06-11  0:00       ` ++           robin
1996-06-11  0:00         ` A. Grant
1996-06-12  0:00           ` ++           robin
1996-06-12  0:00             ` A. Grant
1996-06-14  0:00               ` Richard A. O'Keefe
1996-06-12  0:00           ` Robert Dewar
1996-06-17  0:00             ` A. Grant
1996-06-18  0:00               ` Robert Dewar
1996-06-24  0:00                 ` Robert I. Eachus
1996-06-26  0:00                   ` Norman H. Cohen
1996-06-19  0:00             ` Jon S Anthony
1996-06-20  0:00               ` Robert Dewar
1996-06-24  0:00                 ` Keith Thompson
1996-06-25  0:00                   ` Simon Read
1996-06-25  0:00                   ` Robert A Duff
1996-06-24  0:00                 ` Dale Stanbrough
1996-06-24  0:00                   ` Lars Duening
1996-06-24  0:00                   ` hopkinc
1996-06-24  0:00                   ` Assertions (was: Re: next "big" language?? (disagree)) Robert A Duff
1996-06-24  0:00                     ` Assertions (a different intent?) Gary McKee
1996-06-24  0:00                     ` Assertions (was: Re: next "big" language?? (disagree)) Robert Dewar
1996-06-25  0:00                       ` Robert A Duff
1996-06-28  0:00                         ` Robert Dewar
     [not found]                     ` <4qrljg$15l8@watnews1.watson.ibm.com>
1996-06-28  0:00                       ` Robert Dewar
1996-06-24  0:00                   ` next "big" language?? (disagree) Robert Dewar
1996-06-24  0:00                   ` Adam Beneschan
1996-06-26  0:00                   ` Marc C. Brooks
1996-06-26  0:00                   ` Marc C. Brooks
     [not found]                   ` <4qsbm7$r1s@Starbase.NeoSoft.COM>
1996-06-28  0:00                     ` "Assert"? "Assume"? (was: next "big" language?? (disagree)) Alexander Bunkenburg
1996-06-28  0:00                       ` Ian Collier
1996-07-01  0:00                     ` Cameron Laird
1996-06-24  0:00                 ` next "big" language?? (disagree) Adam Beneschan
1996-06-25  0:00                 ` Darin Johnson
1996-06-26  0:00                   ` Dale Stanbrough
1996-06-26  0:00                   ` A. Grant
1996-06-25  0:00                 ` Brian Nettleton @pulsar
1996-06-26  0:00                   ` Robert Dewar
1996-06-28  0:00                     ` Fergus Henderson
1996-06-28  0:00                       ` Robert Dewar
1996-06-30  0:00                         ` Fergus Henderson
1996-06-30  0:00                           ` Robert Dewar
1996-06-12  0:00         ` Richard A. O'Keefe
1996-06-12  0:00           ` ++           robin
1996-06-12  0:00             ` Richard A. O'Keefe
1996-06-13  0:00               ` ++           robin
1996-06-13  0:00               ` ++           robin
1996-06-12  0:00   ` Jon S Anthony
1996-06-14  0:00   ` Jon S Anthony
1996-06-15  0:00   ` Jon S Anthony
1996-06-18  0:00     ` Adam Beneschan
1996-06-18  0:00   ` Jon S Anthony
1996-06-28  0:00     ` Assertions (an heretic view) Michel Gauthier
1996-06-28  0:00       ` Robert A Duff
1996-06-28  0:00       ` Robert Dewar
1996-06-06  0:00 ` next "big" language?? (disagree) Dale Pontius
1996-06-11  0:00 ` Jon S Anthony
1996-06-12  0:00 ` Help making ada pretty Pedro de las Heras
1996-06-18  0:00 ` next "big" language?? (disagree) ++           robin
1996-06-07  0:00 Ian Ward
1996-06-08  0:00 ` O'Connor
1996-06-10  0:00   ` Matt Kennel
1996-06-11  0:00     ` Ian Ward
1996-06-12  0:00       ` Norman H. Cohen
1996-06-11  0:00     ` Robb Nebbe
1996-06-09  0:00 ` Robert Dewar
replies disabled

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