From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 9 Apr 93 14:06:50 GMT From: usenet.ufl.edu!travis.csd.harris.com!ada1.ssd.csd.harris.com!danr@gatech. edu (Dan Rittersdorf) Subject: Re: and then Message-ID: <1q3vtq$2lt@travis.csd.harris.com> List-Id: In article <1993Apr7.162133.3564@nosc.mil> sampson@nosc.mil (Charles H. Sampson ) writes: > > Unfortunately, that style can conflict with efficiency considerations. >Ada compiler writers appear to have abdicated their responsibility and make >no attempt to determine when boolean operations can be optimized as short- >circuit. (Somebody contradict me, please.) They apparently feel that if >the programmer wants short-circuit he can ask for it. In addition, there >are cases when it is unreasonable to expect such an optimization; when the >second operand contains a function reference, for example. > > Charlie Charlie, Some vendors, especially those that have concentrated on excellent optimization, like (blatant plug alert) Harris, do make this optimization when it can be determined that the operands of the boolean operator have no side effects. Someone else also stated that the LRM requires the evaluation of the operands, but I think several people have done a good job of arguing that one to the ground, so I won't. I find it odd, though, that you feel a vendor has some *responsibility* to provide this optimization. Each possible optimization has a cost and a benefit -- to the vendor and the user, and each vendor decides what optimizations they can afford to provide, given the benefit (profit) that can be obtained. That's business. If a vendor decides that benefits of providing short circuit boolean optimizations don't outweigh their investment, they may well decide not to provide it. They have no responsibility to provide it -- just the option. If you want it, let your vendor know. They can't know what the customer wants if the customer doesn't tell them. If they're unresponsive, remember that they still have to weigh the benefit to their entire user community against the cost to the same. Sometimes one user's request can't be granted if the impact to the entire user community would be deemed too great (for example, if the requested optimization were to require adding a new, time consuming pass to the compiler which would increase everybody's compile times). Note: I'm not implying that the short circuit optimization would require a cost of that magnitude -- those are separate examples...) The language provides two forms of the operators, and one requires short circuiting. If that's what you want, say so; compilers don't have dwim switches yet. If you don't care, use the general form of the operator, but in doing so, you inform the compiler that short circuiting is NOT required, so don't be surprised if you don't get it. I hope this doesn't sound like a flamer -- if so, my apologies. I just wanted to provide a vendor perspective on the issue. And you did ask for contradictions... :-) -- -danr ______________________________________________________________________________ Dan Rittersdorf danr@ada1.ssd.csd.harris.com Harris Corporation, Computer Systems Division, Fort Lauderdale, FL 33309 Michigan Address: 233 Pippin Drive, Sparta, MI 49345 ______________________________________________________________________________