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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,912597791e813f68 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-08 09:25:34 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: gautier_niouzes@hotmail.com (Gautier) Newsgroups: comp.lang.ada Subject: Re: advantages or disadvantages of ADA over pascal or modula Date: 8 Jan 2003 09:25:24 -0800 Organization: http://groups.google.com/ Message-ID: <17cd177c.0301080925.6c30b58d@posting.google.com> References: <17cd177c.0301080101.3f826bab@posting.google.com> NNTP-Posting-Host: 213.173.163.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1042046724 26244 127.0.0.1 (8 Jan 2003 17:25:24 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 8 Jan 2003 17:25:24 GMT Xref: archiver1.google.com comp.lang.ada:32752 Date: 2003-01-08T17:25:24+00:00 List-Id: Martin Klaiber: > Will this really work like that? Calendar.Month must not be set to 1 > if IncYear fails. Does this mean, if exception Year_out_of_range is > raised, the rest of the code in IncMonth will be skipped? It will. Nothing is worth a little test: --8<-----8<-----8<-----8<-----8<-----8<-----8<--- with Ada.Text_IO; use Ada.Text_IO; procedure test_exception is subtype type_Month is Natural; subtype type_Year is Natural; type type_Calendar is tagged record Month : type_Month; Year : type_Year; end record; Year_out_of_range: exception; procedure IncYear (Calendar : in out type_Calendar) is begin if Calendar.Year < 3000 then Calendar.Year := Calendar.Year + 1; else raise Year_out_of_range; end if; end IncYear; procedure IncMonth (Calendar : in out type_Calendar) is begin if Calendar.Month = 12 then IncYear (Calendar); Put_Line("[ Trace point 1 ]"); Calendar.Month := 1; else Calendar.Month := Calendar.Month + 1; Put_Line("[ Trace point 2 ]"); end if; end IncMonth; procedure Test( c: type_Calendar ) is cobbaye: type_Calendar:= c; begin IncMonth( cobbaye ); exception when Year_out_of_range => Put("Kaboom - too far in the future"); end; begin Test((12,2000)); Test((11,3000)); Test((12,3000)); end; --8<-----8<-----8<-----8<-----8<-----8<-----8<--- Output is as expected [ Trace point 1 ] [ Trace point 2 ] Kaboom - too far in the future ________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!