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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fd8f3d2ebf73a4b7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-21 08:51:51 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail Message-ID: <3BFBDBDC.DC6FA8DE@home.com> From: Mark Biggar X-Mailer: Mozilla 4.78 [en]C-{C-UDP; EBM-SONY1} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Whether to raise exception or End_of_List function References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Wed, 21 Nov 2001 16:51:50 GMT NNTP-Posting-Host: 24.250.143.171 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 1006361510 24.250.143.171 (Wed, 21 Nov 2001 08:51:50 PST) NNTP-Posting-Date: Wed, 21 Nov 2001 08:51:50 PST Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:16796 Date: 2001-11-21T16:51:50+00:00 List-Id: Preben Randhol wrote: > > Hi > > I have made a simple double linked list that I use in the application I > develop. Before somebody suggest I use some other libraries I want to > say that I made this double linked list to learn Ada 95 and get aware of > different problems/aspects of implementing this, so at least for this > application I want to keep it for now. > > The list code can be viewed here: http://www.pvv.org/~randhol/Ada95/List/ > Note that the code is still rough, I haven't removed some debugging > functions/procedures etc... > > I put this into a package: > > package Examine_List is > new Double_Linked_List (Data_Type => Natural); > > Main_Examine : Examine_List.List_Type := Examine_List.New_List; > > And use the Main_Examine. So far it has worked nicely, but now I came to > that at one place (at least) in my application I have to go from the > current position of the iterator until the end of the list. I cannot > know the current position of the list iterator so I cannot use a > for-loop. If I want to use a while loop however there are the problem of > knowing when the end of the list is reached. I guess I can make a > function End_of_List (which must also work if one try to backwards in > the list) or I can just raise an exception when the user tries to > step off the list. > > My question is which is the better solution; Exception or a End_of_List > function and which would have fewer side effects? Even though it may seem redundant, you should have both. You need the exception to handle illegal list usage notification. But, as a general rue of thumb for packages of this type, such a package should provide test functions that pre-test for exceptional conditions so a user can program around the exception. -- Mark Biggar mark.a.biggar@home.com