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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!aioe.org!not-for-mail From: =?iso-8859-15?Q?Yannick_Duch=EAne_=28Hibou57=29?= Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Fri, 20 Aug 2010 23:04:26 +0200 Organization: Ada At Home Message-ID: References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <4c6bc259$0$6887$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: C0dyV9+bbkFboHRKTUMzpg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.61 (Win32) Xref: g2news1.google.com comp.lang.ada:13545 Date: 2010-08-20T23:04:26+02:00 List-Id: > I thought discriminant really was like C's union, allocating enough room > for any possible sub-object to fit Depends if it has a default discriminant or not. If it has, and you declare an object of such a discriminated type somewhere, without initialization, you will got nearly the same, except that in Ada you will not be allowed to change arbitrary members without regards to the actual discriminant. If you want to change it, you will have to assign the object as a whole, to give both the new discriminant and the value of the members which will comes into live with it. If on the other hand, if an object is declared using a constrained subtype, either via initialization (this gives the object the subtype of the value used to initialize it) at declaration or because it provides a discriminant at the declaration (which is required if there is no default value for the discriminant), then this have nothing in common with C's union. The structure of the object may be frozen or not (will not in the first case, will be in the second case). And if it is frozen, you cannot change it, so cannot make (and need not) make assumption about its actual internal layout.