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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dc9636dd2392f5bd X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: Problem with function return Date: 2000/04/03 Message-ID: <38E8C166.3BA83AE0@mail.com>#1/1 X-Deja-AN: 606108812 Content-Transfer-Encoding: 7bit References: <38e7a0c8$0$17676@businessnews.de.uu.net> <8F0AB9788synoptikdamudderfuck@news> <8c96al$rr5$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sunrise.ch X-Trace: news1.sunrise.ch 954777963 13518 195.141.231.162 (3 Apr 2000 16:06:03 GMT) Organization: Usenet provided by sunrise communications ag Mime-Version: 1.0 NNTP-Posting-Date: 3 Apr 2000 16:06:03 GMT Newsgroups: comp.lang.ada Date: 2000-04-03T16:06:03+00:00 List-Id: Robert Dewar wrote: > > type color_kind is (nil, red, green, blue); > This seems a bad idea to me, it will result in C-like errors > of the caller forgetting to check for an error, yes it may > be caught, but it is much to easy for it to get swallowed > up, e.g. by the else clause of an if. > > Much better to raise an exception. if the caller wants to handle > it they can put an exception handler at the call site. If they > don't want to handle it, or more likely they forget, then the > exception gets raised and unhandled, which is often better than > blindly carrying on! Of course an exception is best when feasible, but I have used the Nil technique quite often when I need the enumerated type as a discriminant and a default value is required, as in: type R (Color : Color_Kind := None) is record case Color is when None => null; when Red => .... end case; end record;