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!news2.google.com!proxad.net!134.158.69.22.MISMATCH!in2p3.fr!irazu.switch.ch!switch.ch!news.belwue.de!news.uni-stuttgart.de!carbon.eu.sun.com!btnet-feed5!btnet!news.btopenworld.com!not-for-mail From: Martin Dowie Newsgroups: comp.lang.ada Subject: Re: why can't we declare unconstrained objects ? Date: Sun, 12 Dec 2004 18:21:45 +0000 (UTC) Organization: BT Openworld Message-ID: References: NNTP-Posting-Host: host81-152-56-142.range81-152.btcentralplus.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: titan.btinternet.com 1102875705 2557 81.152.56.142 (12 Dec 2004 18:21:45 GMT) X-Complaints-To: news-complaints@lists.btinternet.com NNTP-Posting-Date: Sun, 12 Dec 2004 18:21:45 +0000 (UTC) In-Reply-To: X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) Xref: g2news1.google.com comp.lang.ada:6905 Date: 2004-12-12T18:21:45+00:00 List-Id: Michael Mounteney wrote: > Is there a simple way in Ada of simulating C/C++ unions ? It seems to > me that this is gratuitously prevented, that is, it can be done with > safety, by extending an existing run-time check, but it is in fact > prevented by the compiler. > > Hopefully the following commented source will illustrate my point. > > with Ada.text_IO; > > procedure unconstrained is > > -- Very simple discriminated type > 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"). Cheers -- Martin