home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR9 / A9X_0610.ZIP / 9XOVERVW.HLP < prev    next >
Text File  |  1993-06-10  |  25KB  |  534 lines

  1. Form S101-0892a
  2. 9XOVERVW.HLP
  3.  
  4. Ada Information Clearinghouse, 1-800-AdaIC-11, 703/685-1477
  5.  
  6.                           An Overview of Ada 9X
  7.  
  8.                                S. Tucker Taft
  9.                       Ada 9X Mapping/Revision Team
  10.                             Intermetrics, Inc.
  11.                             733 Concord Avenue
  12.                             Cambridge, MA 02138
  13.  
  14.                              1.  Introduction
  15.  
  16. The Ada programming language, originally approved as an ANSI/MIL standard in 
  17. 1983, and an ISO standard in 1987, is being revised in accordance with ANSI 
  18. and ISO procedures, with a target date for balloting on the revised standard 
  19. in 1993.  The revised language is currently designated "Ada 9X" and is being 
  20. developed through the collaborative efforts of a number of Ada 9X Project 
  21. Teams under the leadership of Christine Anderson at Eglin Air Force Base (now 
  22. at Kirtland AFB).  The Project Teams include:
  23.  
  24. * The Distinguished Reviewer (DR) Team
  25. * The Revision Requirements Team
  26. * The Mapping/Revision Team (MRT)
  27. * The User/Implementor Teams (the UI Teams)
  28. * The Implementation Analysis Team (IAT)
  29. * The Language Precision Team (LPT)
  30. * The Ada Compiler Validation Capability (ACVC) Team
  31.  
  32. In addition, individuals and corporations throughout the world are 
  33. participating in public reviews of the documents produced by the various 
  34. teams.
  35.  
  36. Intermetrics, Inc., is the prime contractor for the Mapping/Revision Team, 
  37. with consultants from the Software Engineering Institute, Argonne National 
  38. Laboratory, Computer Sciences Corporation, the British National Physical 
  39. Laboratory, as well as several private consultants.  The Mapping/Revision Team 
  40. is responsible for proposing specific language changes in response to the 
  41. Revision Requirements Document (December 1990) produced by the Requirements 
  42. Team, and then revising the Ada Reference Manual to reflect the changes 
  43. ultimately selected for inclusion in Ada 9X.
  44.  
  45. The remainder of this extended abstract discusses some of the proposals of the 
  46. Mapping/Revision Team, focusing on those proposals that provide the most 
  47. significant enhancement to the utility of the language.  An expanded form of 
  48. this paper [has later appeared] in a ... special issue of Communications of 
  49. the ACM on the Ada programming language.
  50.  
  51.                          2.  Overview of Changes
  52.  
  53. The Ada 9X Mapping/Revision Team has proposed changes in the following three 
  54. basic areas:
  55.  
  56. * Object-Oriented Programming
  57. * Programming in the Large
  58. * Real-Team and Parallel Programming
  59.  
  60.                    2.1.  Object-Oriented Programming
  61.  
  62. Ada 83 has been called an "object-based" language, but it does not qualify as 
  63. a true "object- oriented" language because it lacks full support for 
  64. inheritance and run-time polymorphism.  For Ada 9X, we have proposed to 
  65. generalize the existing "object-based" features of Ada to allow them to fully 
  66. support object-oriented programming.
  67.  
  68. Ada 83 has a rich abstract type definition capability.  Furthermore, it allows 
  69. one type to be defined as a "derivative" of another.  However, it does not 
  70. allow additional components to be added to the type as part of this 
  71. derivation.  For Ada 9X, we are generalizing the type derivation capability by 
  72. allowing private and record types to be "extended" with additional components.
  73.  
  74. For example, in Ada 83 a new type may be defined in terms of an existing type 
  75. as follows:
  76.  
  77.   type Fancy_Window is new Basic_Window;
  78.  
  79. This new type (Fancy_Window) inherits the same set of components as 
  80. Basic_Window, and the same set of "primitive" operations.  In addition, new 
  81. operations may be defined, and inherited operations may be overridden.
  82.  
  83. For Ada 9X, we allow new components to be defined as part of a type 
  84. derivation, as follows:
  85.  
  86.   type Fancy_Window is new Basic_Window
  87.     with record
  88.       Border_Width : Pixel_count := 1;
  89.       Border_Color : Color := Black;
  90.     end record;
  91.  
  92. Now, the new type Fancy_Window has all of the components of a Basic_Window, 
  93. plus two additional components to allow more control over the appearance of 
  94. the border.  If the names and types of these new components are to be kept 
  95. "private" to the package in which the derived type is defined, a private 
  96. extension part may be specified:
  97.  
  98.   type Fancy_Window is new Basic_Window with private;
  99.  
  100. In the "private" part of the package, the actual components of the extension 
  101. part must be specified.
  102.  
  103. Because of Ada 83's preexisting support for derived types, this modest 
  104. generalization is adequate to provide full support for what is called "single 
  105. inheritance."  However, to provide run-time polymorphism, additional language 
  106. enhancements are required.  We used the existing Ada 83 concept of "universal" 
  107. types and type "classes" as the basis for our proposals for run- time 
  108. polymorphism.
  109.  
  110. In Ada 83, integer literals are defined to be a "universal" integer type, 
  111. which implicitly convertible to any integer type.  Similarly, real literals 
  112. are defined to be of a universal real type, convertible to any real type.  The 
  113. set of all integer types forms the integer "class" of types in Ada 83.  
  114. Similarly, the set of all real types forms the real "class."
  115.  
  116. For Ada 9X, we have generalized the concept of "class" to refer to any set of 
  117. types formed from the direct and indirect derivatives of a given type.  
  118. Furthermore, we have generalized the universal numeric type concept to the 
  119. concept of a "class-wide" type, which can be used to define universal or 
  120. "class-wide" operations that are as convenient to use with any type in a 
  121. class, as are integer literals with any type in the integer class.
  122.  
  123. Such a generalized "class-wide" type is named using attribute notation: For 
  124. any "specific" type T, the "class-wide" type T'CLASS exists and may be used to 
  125. define class-wide operations, and class-wide access types.  For example, given 
  126. our Basic_Window type above, the class-wide type Basic_Window'CLASS exists, 
  127. and may be used to define operations that manipulate objects of type 
  128. Basic_Window or any type derived from it, as follow:
  129.  
  130.   procedure Flash_Window(W : Basic_Window'CLASS) is
  131.     -- This "class-wide" operation flashes a window
  132.     -- by using its Hide and Display primitive operations
  133.     -- repeatedly.
  134.   begin
  135.       Hide(W);
  136.       Display(W);
  137.       Hide(W);
  138.       Display(W);
  139.   end Flash_Window;
  140.  
  141. Because the formal parameter type is Basic_Window'CLASS, the Flash_Window 
  142. operation may be applied to any object whose type is in the "class" of type 
  143. descended from Basic_Window.  Note that the implementation of a class-wide 
  144. operation normally uses the "primitive" operations of the "root" type 
  145. (Basic_Window), in this case, Hide and Display.
  146.  
  147. "Run-time polymorphism" occurs whenever an object of a class-wide type is 
  148. passed to one of the primitive operations -- an automatic dispatch is 
  149. performed to the "appropriate" implementation of the primitive operation.  In 
  150. this example, on each call of Hide and Display with the class-wide parameter 
  151. W, an indirect call is made through a dispatch table identified at run-time by 
  152. a "type tag" carried with each class-wide object.
  153.  
  154. The distinction between specific types and class-wide types is a 
  155. distinguishing feature of Ada 9X.  In Ada 83, user-defined types are always 
  156. "specific" types, and when used as a formal parameter type, the actual 
  157. parameter must have exactly the same type.  In most object-oriented 
  158. programming languages, all types in a type hierarchy are "class-wide," and 
  159. when used as a formal parameter type, the actual parameter may be of that type 
  160. or any of its derivatives.  For Ada 9X, we have explicitly distinguished these 
  161. two concepts, to provide exact type matching by default, while also supporting 
  162. class-wide type matching when explicitly desired.
  163.  
  164. To summarize the Ada 9X support for object-oriented programming: record and 
  165. private types may be extended as part of type derivation to support general 
  166. single inheritance; class-wide types provide class-wide type matching, and use 
  167. automatic dispatching when passed to a primitive operation to provide run-time 
  168. polymorphism.
  169.  
  170.                      2.2.  Programming in the Large
  171.  
  172. Ada 83 has been successfully used in the development of very large programs, 
  173. including those over a million line of code.  However, there can be serious 
  174. practical problems, when developing such large systems, associated with small 
  175. changes resulting in large amounts of recompilation or relinking, due to the 
  176. requirement for strong type checking across separately compiled program units.  
  177. Even with a very fast compiler, it may be impractical to recompile or relink 
  178. certain subsystems, due to configuration management and strict quality 
  179. assurance and testing considerations.
  180.  
  181. For Ada 9X, we have addressed some of the issues associated with "programming 
  182. in the large" by enhancing the separate compilation facilities, as well as 
  183. standardizing mechanisms for breaking large applications into separately 
  184. linkable "partitions," which can be loaded and elaborated independently from 
  185. one another while preserving strong typing.
  186.  
  187. Ada 83 has excellent separate compilation facilities, enforcing full strong 
  188. type-checking across separately compiled units of the application.  However, 
  189. the namespace for "library units" (the basic independently compilable unit of 
  190. an application) is flat.  For Ada 9X, we have proposed that library unit names 
  191. may form a hierarchy.  The program library becomes a forest of library unit 
  192. trees, with each "root" library unit named with a single identifier, and 
  193. "child" library units named by a sequence of identifiers separated by periods.
  194.  
  195. As an example of child library units, we show a hypothetical windowing 
  196. user-interface subsystem, following up on the object-oriented programming 
  197. examples given above:
  198.  
  199.   package Window_System is
  200.     -- This package defines the types that form the
  201.     -- basis of the window system.
  202.     -- Child Library units are used to provide additional
  203.     -- types and operations.
  204.  
  205.       type Window_Id is private;
  206.       type Pixel_Number is new Integer
  207.       subtype Pixel_Count is Pixel_Number range 0..Pixel_Number'LAST;
  208.  
  209.       type Point is -- A point on a two-dimensional screen
  210.         record
  211.           X, Y : Pixel_Number;
  212.       end record;
  213.  
  214.       type Basic_Window is tagged limited private;
  215.                   -- the "root" of the hierarchy of window types
  216.  
  217.       -- Here are the "primitive" operations of Basic_Window.
  218.       -- These "dispatch" automatically when passed
  219.       -- a class-wide object (of type Basic_Window'CLASS).
  220.  
  221.       procedure Create_Window(
  222.         Win : in out Basic_Window;
  223.         Lower_Left : Point;
  224.         Upper_right : Point);
  225.  
  226.       procedure Display(Win : in Basic_Window);
  227.       procedure Hide(Win : in Basic_Window);
  228.       function Id(Win : Basic_Window) return Window_Id;
  229.  
  230.   private
  231.     -- Here are the full declarations of the private types.
  232.  
  233.       type Window_Id is new Integer;
  234.  
  235.       type Basic_Window is tagged
  236.         record
  237.           Id : Window_Id;
  238.           Lower_Left : Point;
  239.           Upper_Right : Point;
  240.         end record;
  241.   end Window_System;
  242.  
  243.   package Window_System.Bells_And_Whistles is
  244.     -- This "child" library unit defines a type extension
  245.     -- of the root window type.
  246.  
  247.       type Fancy_Window is new Basic_Window with private;
  248.  
  249.       procedure Display(FW : in Fancy_Window);
  250.         -- The inherited Display primitive
  251.         -- operation is being overridden
  252.  
  253.   private
  254.       type Fancy_Window is new Basic_Window with
  255.         record
  256.           . . . (as in earlier example) 
  257.         end record;
  258.   end Window_System.Bells_And_Whistles;
  259.  
  260.   with Window_System.Bells_And_Whistles;
  261.   procedure Test is
  262.     -- This procedure uses the child Library unit
  263.       Win : Window_System.Bells_And_Whistles.Fancy_Window;
  264.   begin
  265.       ...
  266.   end Test;
  267.  
  268. Going along with this hierarchical name space enhancement is the 
  269. generalization of the concept that units logically nested within a parent unit 
  270. may "see" the private declarations of the parent unit, and thereby effectively 
  271. extend the functionality of the private types declared in the parent unit.  By 
  272. using child library units, the set of operations of a private type may be 
  273. broken up into logical groupings, rather than being provided in a single 
  274. monolithic package.
  275.  
  276. The hierarchical name space allows a very large application to be organized 
  277. into a set of subsystems, each composed of a tree of library units.  
  278. Furthermore, when a subsystem needs to be extended to service additional 
  279. clients, one may add child library units rather than edit preexisting library 
  280. units, thereby eliminating any disturbance (or recompilation) of existing 
  281. clients of the subsystem.  Furthermore, by keeping individual library units 
  282. smaller and placing logically separable functionality in child library units, 
  283. changes to child library units will affect only those clients interested in 
  284. that particular part of the subsystems.
  285.  
  286. In addition to adding flexibility to library unit naming, we have also 
  287. proposed to add flexibility to the definition of a "program."  In Ada 83, all 
  288. of the library units of a program were loaded and elaborated together.  
  289. However, for large systems, it is often more appropriate for a conceptual 
  290. "program" to actually be composed of independently loaded and elaborated 
  291. pieces.  For Ada 9X, we have formalized this concept, using the term 
  292. "partition" to represent the unit of a system that is loaded and elaborate at 
  293. one time, while explicitly allowing such partitions to communicate with other 
  294. partitions using shared packages and (remote) subprogram calls.  This approach 
  295. preserves the benefits of strong type checking, while allowing program 
  296. partitions to be loaded and updated incrementally.  This can be critical for a 
  297. long-running system, as well as for a fault-tolerant system.
  298.  
  299. In the "core" of the language standard, we proposed to allow programs to be 
  300. broken up into independently elaboratable partitions.  In an annex devoted to 
  301. support for distribution, we propose a set of pragmas to provide a standard 
  302. set of capabilities for partitioning programs.  In the annex, we define two 
  303. kinds of partitions: "passive" partitions, consisting of shared data, but no 
  304. thread of control; and "active" partitions, consisting of one or more threads 
  305. of control, communicating with other active partitions using remote subprogram 
  306. calls and data stored in passive partitions.
  307.  
  308.                2.3.  Real-time and Parallel Programming
  309.  
  310. Ada 83 is one of the few "mainstream" programming languages with support for 
  311. multiple threads of control (tasks) incorporated into the language syntax.  
  312. Ada also incorporates syntactic support for high-level synchronization between 
  313. tasks, based on the "rendezvous" concept.  For many application areas, the 
  314. synchronous task-to-task communication capability inherent in the rendezvous 
  315. has been adequate for building multi-tasking systems.  However, in other 
  316. application areas, a lower-level or asynchronous communication capability is 
  317. required.
  318.  
  319. Ada 83 does not preclude the provision of efficient synchronous communication 
  320. capabilities through the use of implementation-defined packages or specialized 
  321. pragmas.  However, the fact that only synchronous communication is supported 
  322. directly in the language has led to some user dissatisfaction, since the 
  323. approaches based on implementation-defined packages or specialized pragmas are 
  324. inherently less portable and generally less elegant.
  325.  
  326. For Ada 9X, we have proposed to provide language support for synchronous 
  327. communication by providing a data-oriented synchronization "building block" 
  328. called a "protected record," to complement the synchronous task-to-task 
  329. communication capability represented by rendezvous.
  330.  
  331. A protected record is a combination of record components plus "protected 
  332. operations," which have exclusive access to the components.  A protected 
  333. record type is specified by a program unit that defines the components and the 
  334. protected operations, that are either read-only "protected functions," 
  335. read/write "protected procedures," or potentially suspending entries 
  336. (analogous to task entries).
  337.  
  338. Here is an example of a "mailbox" protected record type, defined in a generic 
  339. package:
  340.  
  341.   generic
  342.       type Message_Type is private;
  343.   package Mailbox_Pkg is
  344.       type Message_Array is array(Positive range <>) of Message_Type;
  345.  
  346.       protected type Mailbox(Size : Natural) is
  347.           function Count return Natural;
  348.             -- Count of messages in the Mailbox
  349.           procedure Discard_All;
  350.             -- Discard all messages in the mailbox
  351.           entry Put(Message : in Message_Type);
  352.             -- Put a message into the mailbox;
  353.             -- suspend until there is room
  354.           entry Get(Message : out Message_Type);
  355.             -- Get a message from the mailbox;
  356.             -- suspend until there is a message.
  357.       private record
  358.         -- Define the components of the protected record:
  359.           Contents : Message_Array(1..Size);
  360.             -- This array holds the messages
  361.           Current_Count : Natural := 0;
  362.             -- Count of messages in the mailbox
  363.           Put_Index : Positive := 1;
  364.             -- Index into array for adding next message
  365.           Get_Index : Positive := 1;
  366.             -- Index into array for moving next message
  367.       end Mailbox;
  368.   end Mailbox_pkg;
  369.  
  370. This generic package may be implemented as follows:
  371.  
  372.   package body Mailbox_Pkg is
  373.  
  374.       protected body Mailbox is
  375.           function Count return Natural is
  376.             -- Count of messages in the Mailbox
  377.           begin
  378.             return Current_Count
  379.       end Count;
  380.  
  381.       procedure Discard_All is
  382.         Discard all messages in the mailbox
  383.       begin
  384.           count := 0;
  385.           -- Reset the array indices as well
  386.           Put_Index := 1;
  387.           Get_Index := 1;
  388.       end Discard_All;
  389.  
  390.       entry Put(Message : in Message_Type) when Count < Size is
  391.         -- Put a message into the mailbox.
  392.         -- "Count < Size" is the "barrier" for this entry.
  393.         -- Any caller is suspended until this is true.
  394.       begin
  395.           -- Insert new message, bump index (cyclicly)
  396.           -- and increment counter
  397.           Contents(Put_Index) := Message;
  398.           Put_Index := Put_Index mod Size + 1;
  399.           Count := Count + 1;
  400.       end Put;
  401.  
  402.       entry Get(Message : out Message_Type) when Count > 0 is
  403.         -- Get next message from the mailbox.
  404.         -- "Count > 0" is the "barrier" for this entry.
  405.         -- Any caller is suspended until this is true.
  406.       begin
  407.           -- Get next message, bump index (cyclicly)
  408.           -- and decrement counter
  409.           Message := Contents(Get_Index);
  410.           Get_Index := Get_Index mod Size + 1;
  411.           Count := Count - 1;
  412.       end Get;
  413.     end Mailbox;
  414.   end mailbox_Pkg;
  415.  
  416. As illustrated above, each protected operation specified in the protected type 
  417. definition must have a body provided in the protected body.  Furthermore, each 
  418. entry body must have an "entry barrier" specified after the reserved word 
  419. "when."  Any caller of any entry is automatically suspended if the entry 
  420. barrier is false, on an entry queue associated with the entry.
  421.  
  422. Upon completion of a protected procedure or entry, the components of the 
  423. protected may have changed, so the entry barriers are rechecked to see if one 
  424. of them has become true.  If so, the first caller on the associated entry 
  425. queue is selected and the entry body is executed for the caller.  This process 
  426. of "servicing the entry queues" continues until there are no more callers on 
  427. entries with true barriers.
  428.  
  429. To use the generic package from the above example, one instantiates it with 
  430. some message type, and then declares an instance of the Mailbox type.
  431.  
  432. Protected operations are performed by using a subprogram call syntax, but with 
  433. the protected record object identified by a prefix to the operation name.  
  434. This is illustrated in the following example:
  435.  
  436.   with Text_IO, Mailbox_Pkg;
  437.   procedure Test is
  438.       type Line is record
  439.         -- The type to be used for messages
  440.           Length : Natural := 0;
  441.           Data : String(1..80);
  442.       end record;
  443.  
  444.       package Line_Buffer_Pkg is
  445.         new Mailbox_Pkg(Message_Type => Line);
  446.  
  447.       Line_Buffer : Line_Buffer_Pkg.Mailbox(Siz => 20);
  448.         -- Instance of mailbox with room for 20 messages
  449.  
  450.       task Producer;  -- Task that will put messages into mailbox
  451.       task body Producer is
  452.           L : Line;
  453.       begin
  454.           for I in 1..100 loop
  455.               Text_IO.Get_Line(L.Data, L.Length)
  456.                 -- Read a line from Standard_Input
  457.               Line_Buffer.Put(L);  -- Entry call to put message
  458.           end loop;
  459.       end Producer;
  460.  
  461.       task Consumer; -- Task that will get message out of mailbox
  462.       task body Consumer is
  463.           L : Line;
  464.           C : Natural;
  465.       begin
  466.           for I in 1..100 loop
  467.               Line_Buffer.Get(L);  -- Entry call to get message
  468.               Text_IO.Put_Line(L.Data(1..L.Length));
  469.                 -- Write the line to Standard_Output
  470.  
  471.               -- Check if Consumer is falling way behind Producer
  472.               C := Line_Buffer.Count(L);  -- Protected func call
  473.               if C > Line_Buffer.Size/2 then
  474.                   -- Report that Consumer is falling way behind
  475.                   Text_IO.Put_Line("****Buffer count now =" &
  476.                     Integer'IMAGE(C));
  477.               end if;
  478.           end loop;
  479.       end Consumer;
  480.   begin
  481.       null;  -- Wait for tasks to complete
  482.   end Test;
  483.  
  484. Entry calls on protected record entries may be used anywhere (task) entry 
  485. calls are permitted in Ada 83, in particular in conditional and timed entry 
  486. call statements.
  487.  
  488. Protected records, with their support for efficient mutual exclusion and 
  489. asynchronous signaling via entry barriers, are the most important addition to 
  490. Ada 9X for real-time and parallel programming.  In addition, we have proposed 
  491. other enhancements, including a more general form of selective entry call, and 
  492. a requeue capability so that a server can examine the parameters of an entry 
  493. call before committing to servicing the call.  Finally, a real-time "annex" 
  494. has been proposed where standardized packages and pragmas are defined that 
  495. will provide dynamic priority control, a "monotonic" real-time clock, and a 
  496. CPU time accounting capability.
  497.  
  498.                                 3.  Summary
  499.  
  500. The capabilities of Ada 83 are being enhanced through the definition of a 
  501. small number of new "building blocks" in three basic areas, object-oriented 
  502. programming, programming in the large and real-time and parallel programming.  
  503. In each case, we have used existing features as the basic for the enhanced 
  504. capabilities: Derived and universal types provide the basis for object- 
  505. oriented programming; the existing library unit concept forms the basis for 
  506. the hierarchical name space and program partitioning; and the concepts of 
  507. private types, functions, procedures, and entries form the basis for the 
  508. protected record construct, supporting fast mutual exclusion and asynchronous 
  509. task communication.
  510.  
  511. Revising a standard language is always a difficult task, with a tension 
  512. between the goal of appealing to new users and supporting new and challenging 
  513. application areas, and the goal of minimizing disruption to existing users and 
  514. existing applications.  We believe that the proposals for Ada 9X represent a 
  515. natural evolution of the existing excellent Ada 83 capabilities, while 
  516. ensuring that Ada can be used efficiently and productively to solve the 
  517. complex systems implementation problems of the 90s.
  518.  
  519.                             **********************
  520.  
  521.                        Reprinted with permission.
  522.  
  523.                  Ada Information Clearinghouse (AdaIC)
  524.                                P.O. Box 46593
  525.                        Washington, DC  20050-6593
  526.              703/685-1477, 800/AdaIC-11, FAX 703/685-7019
  527.            adainfo@ajpo.sei.cmu.edu; CompuServe 70312,3303
  528.  
  529. The AdaIC is sponsored by the Ada Joint Program Office and operated by IIT 
  530. Research Institute.
  531.  
  532.  
  533.  
  534.