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: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public From: donh@syd.csa.com.au (Don Harrison) Subject: Re: "(Sub)type" -safety Date: 1997/01/30 Message-ID: #1/1 X-Deja-AN: 213173755 sender: news@syd.csa.com.au x-nntp-posting-host: dev50 references: organization: CSC Australia, Sydney reply-to: donh@syd.csa.com.au newsgroups: comp.lang.eiffel,comp.lang.ada Date: 1997-01-30T00:00:00+00:00 List-Id: Jon S Anthony writes: :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 Agree. :> 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. Agree. Jon, I'm speechless! We actually seem to agree. :) Don. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Don Harrison donh@syd.csa.com.au