Beaujolais effect

Beaujolais effect

Beaujolais effect is the name given to a class of potential semantic errors in Jean Ichbiah's draft specifications for the Ada programming language. The name arose from Ichbiah's promise to give a bottle of Beaujolais red wine to anyone who could find such a situation in the draft language standard. At least one bottle was actually awarded for such a discovery. [ [http://www.adaic.com/learn/oldfaqs.html#beaujolais What is the "Beaujolais Effect"?] ]

Definition

The Beaujolais effect is a situation where adding or removing a single "use clause" in an Ada program changes the behavior of the compiled program, a very undesirable effect in a language designed for semantic precision. Ichbiah took steps to prevent the effect when he updated his draft standard to produce the final Ada 83 language standard. The remaining possible situations for producing the effect were later identified by mathematical analysis and addressed by the Ada 95 language standard, making any situation that still resulted in a Beaujolais effect in Ada 83 an illegal construct in the more recent Ada 95 language standard.

The Beaujolais Effect can in principle occur in other languages that use namespaces or packages as well, if the language specification does not take care to make it illegal.

Background

The Ada programming language allows source code to be broken up into "library packages" containing definitions of data and algorithms that can be used by programs or other library packages. The definitions in a package are made visible by a "with clause". For example, if the line –

with Ada.Text_IO;

appears at the top of the source code for a program or package then the data, procedures, and functions declared in the library package "Ada.Text_IO" can be invoked within that source code. This is the implementation of the "namespace" concept for Ada.

Thus a program that has the with Ada.Text_IO; directive can "see" the definitions there, and in order to invoke the New_Line procedure in "Ada.Text_IO" it can be referred to by name,

Ada.Text_IO.New_Line;

and similarly with procedures or functions that require arguments, or with reads/writes to any variables declared in the "Ada.Text_IO" package.

However, such fully specified names can become quite verbose, so the language standard also supports a "use clause" that tells the compiler to search the contents of the package when trying to identify names that occur in the source code. Thus if both the lines –

with Ada.Text_IO; use Ada.Text_IO;

appear at the top of a program, the New_Line procedure in the package "Ada.Text_IO" is not only visible to the program, but can be invoked by the abbreviated form –

New_Line;

because the "use clause" tells the compiler what package contains the definition.

However, ambiguity arises if more than one package defines a New_Line procedure with the same or similar parameter profiles. If the program does not resolve the ambiguity, the compiler should reject the program with an error message. Here is an example:

package A is procedure New_Line (Number_Of_Lines : in Positive := 1); end A; with A; use A; with Ada.Text_IO; use Ada.Text_IO; procedure Ambiguous is begin New_Line; "-- error" end Ambiguous;

In the example above, the call is ambiguous because it could correspond to either Ada.Text_IO.New_Line or A.New_Line with the default parameter value. There are two ways to resolve the ambiguity. One is to specify the package name, and the other is to specify the parameter name explicitly, it the subprogram to call has parameters. The four examples below all resolve the ambiguity.

Ada.Text_IO.New_Line; A.New_Line; New_Line (1); New_Line (Number_Of_Lines => 1);

References


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Beaujolais wine — Infobox Wine Region name = Beaujolais type = Appellation d origine contrôlée year = 1936 country = France part of = Burgundy climate region = precipitation = soil = Granite, Schist, Clay and Sandstone total size = 10,500ha planted = grapes =… …   Wikipedia

  • Beaujolais (wine) — This article is about the wine from Beaujolais. For the historical province of France, see Beaujolais (province). Beaujolais (wine region) Type Appellation d origine c …   Wikipedia

  • List of effects — This is a list of names for observable phenonema that contain the word effect, amplified by reference(s) to their respective fields of study. #*3D audio effect (audio effects)A*Accelerator effect (economics) *Accordion effect (physics) (waves)… …   Wikipedia

  • Business and Industry Review — ▪ 1999 Introduction Overview        Annual Average Rates of Growth of Manufacturing Output, 1980 97, Table Pattern of Output, 1994 97, Table Index Numbers of Production, Employment, and Productivity in Manufacturing Industries, Table (For Annual… …   Universalium

  • wine — wineless, adj. winish, adj. /wuyn/, n., adj., v., wined, wining. n. 1. the fermented juice of grapes, made in many varieties, such as red, white, sweet, dry, still, and sparkling, for use as a beverage, in cooking, in religious rites, etc., and… …   Universalium

  • Loire Valley (wine) — Loire Valley (wine region) Country France Sub regions Anjou, Muscadet, Sancer …   Wikipedia

  • Carbonic maceration — is a winemaking technique, often associated with the French wine region of Beaujolais, in which whole grapes are fermented in a carbon dioxide rich environment prior to crushing. Conventional alcoholic fermentation involves crushing the grapes to …   Wikipedia

  • Chardonnay — This article is about the grape variety. For the village in France, see Chardonnay, Saône et Loire. Moreau Blanc redirects here. For another French wine grape that is also known as Moreau Blanc, see Gouais blanc. Gentil Blanc redirects here. For… …   Wikipedia

  • France — /frans, frahns/; Fr. /frddahonns/, n. 1. Anatole /ann nann tawl /, (Jacques Anatole Thibault), 1844 1924, French novelist and essayist: Nobel prize 1921. 2. a republic in W Europe. 58,470,421; 212,736 sq. mi. (550,985 sq. km). Cap.: Paris. 3.… …   Universalium

  • Viognier — Infobox grape variety name = Viognier caption = Viognier grapes ripening on the vine species = Vitis vinifera color = Green also called = Bergeron, Barbin, Rebolot, Greffou, Picotin Blanc, Vionnier, Petiti Vionnier, Viogne, Galopine, Vugava… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”