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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,820de86ed0dafb8a X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: Help Me Please :) Date: 2000/03/18 Message-ID: <8b0ihj$sli$1@nntp9.atl.mindspring.net>#1/1 X-Deja-AN: 599263284 References: <89rlvr$gn9$1@nntp3.atl.mindspring.net> Organization: MindSpring Enterprises X-Server-Date: 18 Mar 2000 18:39:47 GMT Newsgroups: comp.lang.ada Date: 2000-03-18T18:39:47+00:00 List-Id: In article , Robert A Duff wrote: >Richard D Riehle writes: > >> In some languages, exceptions are first class objects. >> Ada exceptions are not first class objects for very good reasons. > ^^^^^^^^^^^^^^^^^ >>I beg to differ. I think this is one of the few cases where those other >languages got it right, and Ada got it wrong. Delighted to have this response from you. I have been spending some time with C++ lately and find the exception model to be confusing, error-prone, and more complicated than necessary. One reason I like the Ada model is its simplicity compared to other languages. We can agree to disagree on this. >If you want strings, Ada.Exceptions works OK (although it's annoying to >have "exceptions" and "Exception_Ids", which are both essentially >representations of the same concept). If you want to attach some other >type of data to an exception, you're stuck with several poor >alternatives: You could encode that data as a String, but then you lose >type checking -- the declaration of an exception ought to declare the >type of attached data, forming a compile-time-checkable contract between >the raise point and the handler point. Or you could store the >information in a global, but then you lose task safety, and there are >issues of exactly when that global data is valid. Etc. For embedded systems, one does not want to be, in the words of Dr. Tokar of DDC-I, ..."passing strings all over the place." Also, for non-embedded systems, not all compilers adequately support the facilities of Ada.Exceptions, especially. Janus and ObjectAda have pretty good support for the function, Exception_Information, but some others do not. The reason for promoting an exception to a typed value has to be compelling. Consequently, it is rarely necessary. In an application such as a non-stop command and control system, one could find compelling reasons for wrapping an exception_occurrence in a tagged type and referring to it during some lull in activity as part of a logging operation. There are other circumstances when promoting an exception to a first-class object might be compelling. In the absence of such compelling circumstances, insisting that an exception be a first-class object simply complicates the entire exception handling process. The Ada solution, which provides the option of promoting it to a first-class object, seems to me the optimal solution. Thanks for you insight on this. I beleive it is an important thread of discussion about Ada, one we do not visit often enough. Richard Riehle richard@adaworks.com