From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79bbf7e359159d0d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-04 22:02:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!cyclone2.usenetserver.com!news-out.usenetserver.com!newsfeed.icl.net!isdnet!enst!enst.fr!not-for-mail From: Wilhelm.Spickermann@t-online.de (Wilhelm Spickermann) Newsgroups: comp.lang.ada Subject: RE: newbie can't get exceptions to work! Date: Thu, 05 Apr 2001 06:59:23 +0200 (CEST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit X-Trace: avanie.enst.fr 986446867 22692 137.194.161.2 (5 Apr 2001 05:01:07 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 5 Apr 2001 05:01:07 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: X-Mailer: XFMail 1.4.0 on Linux X-Priority: 3 (Normal) In-Reply-To: <3ACBE436.4B247767@nmt.edu> X-Sender: 0211750756-0001@t-dialin.net Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.3 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: supernews.google.com comp.lang.ada:6493 Date: 2001-04-05T06:59:23+02:00 On 05-Apr-01 Jeff Shipman wrote: ... > generic > LEN : NATURAL := 100; -- Size of the stack (default 100 > type ELM is private; -- Used to store element type > > package GEN_STACK is > STACK_ERROR : exception; -- Raised when something bad > happens. > > procedure PUSH(E : in ELM); -- Push E into the stack > procedure POP(E : out ELM); -- Pop element from stack; > store > in E > > function FULL return BOOLEAN; -- Returns TRUE if stack is ... > exception > when STACK_ERROR => ... > When I try to compile, I get the following errors: > > use_gen_stack.adb:214:12: "STACK_ERROR" is not visible > use_gen_stack.adb:214:12: multiple use clauses cause hiding What should the program do, if You write "PUSH(4)"? Should it push into INT_STACK or INT2_STACK? You have created six _different_ exceptions, which are all called STACK_ERROR. The compiler cannot possibly know which one You try to handle. You could use names like FLOAT_STACK.STACK_ERROR etc. You will run into the same problems with the other entities of the generic package. Such a "generic abstract data object" is very practical if only one instantiation is needed at every place of use. If You really need several stack in interleaved usage, you need a "generic abstract data type". Wilhelm