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-Thread: 103376,699cc914522aa7c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l53g2000cwa.googlegroups.com!not-for-mail From: "claude.simon@equipement.gouv.fr" Newsgroups: comp.lang.ada Subject: Re: Structured exception information Date: 15 Jan 2007 09:17:40 -0800 Organization: http://groups.google.com Message-ID: <1168881460.179633.196040@l53g2000cwa.googlegroups.com> References: NNTP-Posting-Host: 212.23.162.39 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1168881475 15950 127.0.0.1 (15 Jan 2007 17:17:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 15 Jan 2007 17:17:55 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.9) Gecko/20061206 Firefox/1.5.0.9,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 sesame.setra.fr:3128 (squid/2.5.STABLE3) Complaints-To: groups-abuse@google.com Injection-Info: l53g2000cwa.googlegroups.com; posting-host=212.23.162.39; posting-account=SnKwIw0AAABJwJI8idy3oqasZLmqdeAT Xref: g2news2.google.com comp.lang.ada:8138 Date: 2007-01-15T09:17:40-08:00 List-Id: when My_Type is an indefinite subtype. type My_type (<>) is ... for example Then, when you declare an object of that type you must provide an initialization expression (a constructor call !). Maciej Sobczak a =E9crit : > Hi, > > Consider an object created by a constructor function: > > X : My_Type :=3D My_Constructor(Some_Parameters); > > My_Type is Controlled_Limited to ensure control over initialization and > finalization. The idea of constructor function is to prevent the > existence of objects that are not yet initialized, half-baked, in a bad > state, etc. If the object exists, it's ready for use. > > If there are problems during the execution of the constructor function, > the exception is raised, so that there is no X object in a bad state. > How can I pass some error information from the constructor function out, > so that it's used when the exception is handled? > Obviously, some message can be attached to the exception occurence, but > it doesn't scale well - I might want to pass some more data, possibly > structured (some error code, some reason code, some timestamp, some > whatever else, ...). > > Yes, I'm asking for "throwing objects", in the C++ parlance. > > How to do this in Ada? > If I cannot - how to solve this design problem? > > BTW - How can I ensure in a general way that the constructor function > must be used to initialize the object, otherwise compile-time error is > reported? > If I make My_Type a discriminated type (so that the discriminant value > is used in the default initialization), does it limit anything, like > constructor parameter types? > > -- > Maciej Sobczak : http://www.msobczak.com/ > Programming : http://www.msobczak.com/prog/