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=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 26 Apr 93 16:05:59 GMT From: agate!howland.reston.ans.net!noc.near.net!inmet!spock!stt@ucbvax.Berkeley .EDU (Tucker Taft) Subject: Re: "the so-called Beaujolais effect" Message-ID: <1993Apr26.160559.26244@inmet.camb.inmet.com> List-Id: In article <1993Apr23.194731.24560@convex.com> sercely@convex.com (Ron Sercely) writes: >What is this? I have been reading the "Intoducing Ada9X" Ada9X Project >Report, and came across this term on p. 66. Please excuse my ignorance >if this is really well known. If not, a lot of us letters will become >a little less ignorant :-) As a professor would say... "Good Question." The term "Beaujolais effect" was coined during the original Ada 83 design effort, when Jean Ichbiah promised a bottle of Beaujolais to anyone who could find an instance of the following: If one adds or removes a declaration from a package, and that package is "use"d in some compilation unit, the compilation unit remains legal upon recompilation, but has a different meaning. Generally, this doesn't happen in Ada 83 because of the subtle rules for "use" visibility (RM 8.4(5,6)). However, there are some extremely subtle cases of the Beaujolais effect that remain in Ada 83 that are related to the preference against implicit conversion (RM 4.6(15)). Note that an equivalent statement of the Beaujolais effect is that when adding or removing a single "use" clause a compilation unit remains legal but changes meaning. We endeavored to avoid introducing new examples of "Beajolais" effects during the 9X revision, and as part of revising the rules on implicit conversion (as needed to support OOP) we also eliminated the few remaining cases that were present in Ada 83. For those who care, here is an example of a Beaujolais effect in Ada 83 (this comes from the "Ada 9X Compatibility Guide" prepared by Bill Taylor of Transition Technology Limited): package P is procedure Q(B : Boolean); -- Q1 end P; with P; use P; procedure Main is function "<"(X, Y : Integer) return Integer; procedure Q(I : Integer) is ... end Q; -- Q2 begin Q(1 < 2); -- Interpreted as Q1 due to "use P;" -- Would be interpreted as Q2 if Q1 deleted -- from P, or "use P" clause removed. end Main; In Ada 9X, the above compilation unit "Main" would be considered ambiguous, because the preference rule relating to use of integer literals is more locally defined (see RM9X-8.6(29-30);2.0): There is a "preference" for the primitive operators of the root numeric types root_integer and root_real. In particular, if two acceptable interpretations of a constituent of a complete context differ only in that one is for a primitive operator of the type root_integer or root_real, and the other is not, the interpretation using the primitive operator of the root numeric type is "preferred." For an innermost complete context, if there is exactly one overall acceptable interpretation where each constituent's interpretation is the same as or preffered (in the above sense) over those in all other overall acceptable interpretations, then that one overall acceptable interpretation is chosen. Otherwise the complete context is "ambiguous." "Q(1 < 2);" is ambiguous in Ada 9X because the interpretation of Q1(1 < 2) is *not* preferred over Q2(1 < 2) in Ada 9X, since the interpretations differ in more than just their interpretation of "<". They also differ in their interpretation of "Q", which is not a primitive operator of a root numeric type. In Ada 83, Q(1 < 2) is not ambiguous, because the Q1 interpretation does not require any implicit conversions of integer literals, whereas the Q2 interpretation requires some implicit conversions. As it turns out, this change should affect very few (if any) "real" programs, since it only occurs in situations where programmers override predefined operators with "weird" result types. And it only occurs when the "Beajolais" effect was possible, so the affected programs (if any) were potential maintenance time-bombs. >Ron Sercely S. Tucker Taft stt@inmet.com Ada 9X Mapping/Revision Team Intermetrics, Inc. Cambridge, MA 02138