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,e1e2bc096a996632 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!newsfeed-east.nntpserver.com!nntpserver.com!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread3.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: why can't we declare unconstrained objects ? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sun, 12 Dec 2004 18:40:40 GMT NNTP-Posting-Host: 63.186.48.10 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1102876840 63.186.48.10 (Sun, 12 Dec 2004 10:40:40 PST) NNTP-Posting-Date: Sun, 12 Dec 2004 10:40:40 PST Xref: g2news1.google.com comp.lang.ada:6906 Date: 2004-12-12T18:40:40+00:00 List-Id: Martin Dowie wrote: > Michael Mounteney wrote: > >> type thing (what : Boolean) is > > Simply add a default to the discriminant and you can change it all you > want at run-time (e.g. "what : Boolean := Boolean'First"). To be precise (and it sounds as if the OP needs this level of detail), if a discriminated record type has defaults for all discriminants, then you can declare an unconstrained object of the type by not specifying the discriminants: type R (D : Boolean := False) is record ... V : R; ... V := R'(D => True, ...); However, if you declare objects with discriminants specified: X : R (D => False); then the object is constrained and the discriminant cannot be changed. Also, you can only change the discriminant by assigning the entire record. V.D := True; -- illegal If you're interested in interpreting the same bit pattern as 2 different types, this is not the mechanism Ada uses. Use Unchecked_Conversion instead. -- Jeff Carter "Nobody expects the Spanish Inquisition!" Monty Python's Flying Circus 22