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.8 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!ames!ucbcad!ucbvax!sdcsvax!ucsdhub!hp-sdd!hplabs!sdcrdcf!burdvax!eric From: eric@burdvax.UUCP Newsgroups: comp.lang.ada Subject: Re: language problem Message-ID: <3223@burdvax.PRC.Unisys.COM> Date: Mon, 6-Apr-87 08:26:19 EST Article-I.D.: burdvax.3223 Posted: Mon Apr 6 08:26:19 1987 Date-Received: Thu, 9-Apr-87 03:52:16 EST References: <6109@mimsy.UUCP> Sender: news@burdvax.PRC.Unisys.COM Distribution: world Organization: Unisys/Paoli Research Center, Paoli, PA List-Id: in article <6109@mimsy.UUCP>, dday@mimsy.UUCP (Dennis Doubleday) says: > .... But if it is impossible to efficiently handle > type and constraint checking for every possible pathological > boundary condition ... At least in this example, the compiler can determine if the situation could occur at execution time, and take appropriate actions by emitting code for the efficient common situation, or less efficient code for the pathological case. First, the only operators which can partake in this silliness are NOT and XOR, and only if their operand(s) is a subtype of a boolean type constrained to a single value (Yuch). If such a type may exist at execution time, the compiler could emit an if statement like the following. if funny_boolean_type'first != funny_boolean_type'last then emit efficient code for AND and XOR else emit funny code for AND and XOR end if; The funny code for AND is easy, just raise CONSTRAINT_ERROR (what could be more efficient than that :-). For XOR, a component by component test needs to be performed for the detection of CONSTRAINT_ERROR. So it turns out, for efficiency at least, that the XOR operation is the worst case, AND is the best case, and for the common case (a boolean type with both values), an additional if statement is needed. Remember, all of this is only for a boolean type which could turn out to be constrained to only a single value. Eric Marshall Unisys Corporation P.O. Box 517 Paoli, PA. 19301 (215) 648-7223 USENET: sdcrdcf!burdvax!eric {sjuvax,ihnp4,akgua,cadre}psuvax1!burdvax!eric ARPANET: eric@burdvax.prc.unisys.com