From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: f43e6,b87849933931bc93 X-Google-Attributes: gidf43e6,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: "Norman H. Cohen" Subject: Re: OO, C++, and something much better! Date: 1997/01/17 Message-ID: <32DF94DC.6FF8@watson.ibm.com>#1/1 X-Deja-AN: 210432611 references: <32DF458F.4D5C@concentric.net> content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.c++,comp.lang.smalltalk,comp.lang.eiffel,comp.lang.ada,comp.object,comp.software-eng x-mailer: Mozilla 3.0 (Win95; I) Date: 1997-01-17T00:00:00+00:00 List-Id: Alan Lovejoy wrote: > > Matthew Heaney wrote: ... > > Constraint_Error was raised because the range constraint was violated. > > This behavior is similar to the Eiffel behavior when a precondition is not > > satisfied. The terms of the contract between the client (the caller) and > > server (the subprogram) were violated by the client, so an exception was > > raised. Isn't that what you would expect to happen? > > Yep. Just like what happens in a dynamically-typed language: a "message not > understood" exception is raised when an object with the wrong value is sent > a message it can't handle (the class of an object is part of its value in > a dynamically-typed language). Or, to put it another way, the types of a dynamically typed language are like the subtypes (subsets of types defined by constraints checked at run time) of a statically typed language with one type. The advantage of a statically typed language is that it enables the designer to divide the objects the program will be using into groups, so that those objects "understanding a particular message" are in the same group, to adopt the convention that certain variables will only be used for objects in a certain group, and to send messages only to objects in groups that are known to understand them--and to have the compiler enforce these conventions and catch errors before a program is ever executed. (In a strongly-typed language with class-based polymprohism, these groups need not be disjoint, but instead may be nested.) There is ample evidence that errors caught at compile time are less costly to identify and eliminate than errors caught only when a certain point is reached in execution. Furthermore, the greater the number of errors that are caught independent of any particular execution path being taken, the smaller the number of errors that will be present in a delivered product. -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen