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: 16 Dec 91 14:28:02 GMT From: terminus.umd.edu!brad@umd5.umd.edu (Brad Balfour) Subject: Re: Help with Exceptions for Generic Instantiation Message-ID: List-Id: ae@sei.cmu.edu (Arthur Evans) replies: >pattis@cs.washington.edu (Richard Pattis) asks about parameterizing a >generic with an exception. >Well, if you are missing something it's because it isn't there. Ada 83 >has no mechanism to do what you want. Ada 9X will, but that doesn't >help much right now. >Art Evans Well... Not necessarily. Draft 3.1 of the Ada 9X Mapping Specification from August 1991 does not have exceptions as generic formal parameters. And, (IMHO) it doesn't look likel y that this will change unless people demand it. However, the Mapping/Revision Team has proposed another mechanism that might work in this case: Generic formal package parameters. I have attempted to work out Rich's example with the new (as of v3.1) syntax. -- new -- Generic -- must be generic to be passed as a generic formal parameter -- rest is same as before -- PACKAGE File_Stream IS ... END File_Stream; A simple echo utility might then be written as follows (modified for 9X v3.1): WITH Terminal_Utility, String_Utility; -- His own I/O interfaces GENERIC Message : IN STRING; with package A_Stream is new File_Stream(<>) ; -- any instantiation of File_Stream will match this parameter PROCEDURE Echo; PROCEDURE Echo IS PACKAGE SU RENAMES String_Utility; PACKAGE TTY RENAMES Terminal_Utility; S : A_Stream.Stream; C : CHARACTER; BEGIN Open(S, TTY.Prompt(Message)); BEGIN LOOP A_Stream.Get(C, S); TTY.Announce(C); END LOOP; EXCEPTION WHEN A_Stream.No_More_Data_Error => -- now the exception name is visible Close(S); END; TTY.Announce(SU.CR); END Echo; Hope this helps. ------ Brad Balfour EVB Software Engineering, Inc. 1-800-877-1815 brad@terminus.umd.edu