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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2f63c66b1f04412d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-20 02:02:41 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer2.atl.newshosting.com!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.clear.net.nz!news.clear.net.nz.POSTED!not-for-mail NNTP-Posting-Date: Thu, 20 Nov 2003 04:02:38 -0600 From: Craig Carey Newsgroups: comp.lang.ada Subject: Re: How to define an array of a variant record type? Date: Thu, 20 Nov 2003 23:02:42 +1300 Message-ID: References: X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Organization: Customer of Mercury Telecommunications Ltd Cache-Post-Path: drone5.qsi.net.nz!unknown@tnt2-213.quicksilver.net.nz X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/) X-Original-NNTP-Posting-Host: drone5-svc-skyt.qsi.net.nz X-Original-Trace: 20 Nov 2003 23:03:04 +1300, drone5-svc-skyt.qsi.net.nz NNTP-Posting-Host: 203.97.37.6 X-Trace: sv3-velOa+uFy5XP4xIUIvOs5EckyZvBQ/0ioCSx/NtimIUBsREEmAeN+AtIiSUJ/x//xnLh82bBziaXQU8!3h3e7EjJ6GCYOwFTi4XfxMPkRCq7uhxqfT7AL8pgh0b5rIG7lGXyWVf9tyHWHhWmjmOWvWqjCb6d!PfQpNlo= X-Complaints-To: Complaints to abuse@clear.net.nz X-DMCA-Complaints-To: Complaints to abuse@clear.net.nz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:2716 Date: 2003-11-20T23:02:42+13:00 List-Id: On 17 Nov 2003 12:35:34 -0500, Stephen Leake wrote: ... >change this to > >type Name_Value(Value_Type : Name_Value_Type := String_Type) is > > >This seems very odd, but it works. It says to the compiler "let the >discriminant change at runtime". Without the default value for the >discriminant, the discriminant is _not_ allowed to change at runtime; >it must be known at compile time. http://www.adaic.org/standards/95aarm/html/AA-3-7.html AARM 3.7 Discriminants ... NOTES 28 50 If a discriminated type has default_expressions for its discriminants, then unconstrained variables of the type are permitted, and the values of the discriminants can be changed by an assignment to such a variable. If defaults are not provided for the discriminants, then all variables of the type are constrained, either by explicit constraint or by their initial value; the values of the discriminants of such a variable cannot be changed after initialization. 28.a Discussion: This connection between discriminant defaults and unconstrained variables can be a source of confusion. For Ada 95, we considered various ways to break the connection between defaults and unconstrainedness, but ultimately gave up for lack of a sufficiently simple and intuitive alternative. ... Presumably pesons could use Ada for 10 years without figuring that out, except for slow Leake of information at comp.lang.ada. ---- Also there is the pragma Volatile trick (that won't run in GNAT 3.15p due to the caching not going away): the discriminant is altered by using X'Address or similar, and pragma Volatile suppresses the caching.