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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public From: jsa@alexandria (Jon S Anthony) Subject: Re: "(Sub)type" -safety Date: 1997/01/29 Message-ID: #1/1 X-Deja-AN: 213106166 sender: news@organon.com (news) references: <32ECD432.72EE@watson.ibm.com> organization: Organon Motives, Inc. newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1997-01-29T00:00:00+00:00 List-Id: In article donh@syd.csa.com.au (Don Harrison) writes: > Yes, it's true that the closest analogue of Eiffel "subtypes" in Ada > is probably derived types. A bullseye! > Also, I acknowledge that the analogue of > Ada subtypes is not Eiffel "subtypes". A better analogue might be > preconditions on routines. These effectively create (in my mind, if > no-one else's :)) an anonymous "(sub)type". > > eg. do_something (a: INTEGER) is > require in_range: a >= 1 and a <= 10 > ... And another!!!! :-) Really, this is pretty much exactly the right way of comparing the two in this area. It's just that Ada subtypes don't have the flexibility and range (sic) of Eiffel assertions. They are a relatively simple subcase. > :Just as a run-time error can occur in Eiffel > :converting from a type to a subtype (i.e., casting downward in the > :inheritance hierarchy), > > Eiffel's actually a bit different here. This occurs implicitly in two types > of reattachment: > > 1) Reserse assignment attempt (which doesn't cause a runtime error), and Right - I think the Ada analogue here is really its "in" operator: if X in C'Class then -- do something like convert away from root > 2) Operation parameter substitution (which may). And this one is just like converting in Ada without first checking, and can result in a runtime CE. /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com