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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,48bf593f723b7524 X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: Can I have an array of variant records? Date: 1999/04/21 Message-ID: <7fks8u$8k1$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 469136944 References: <371c84fb.0@silver.truman.edu> <87aew3j899.fsf@bglbv.my-dejanews.com> <7fk8c6$mbe$1@nnrp1.dejanews.com> <371DC9BE.585254A6@wbkst21.mach.uni-karlsruhe.de> X-Http-Proxy: 1.0 x15.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Apr 21 15:53:04 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I) Date: 1999-04-21T00:00:00+00:00 List-Id: In article <371DC9BE.585254A6@wbkst21.mach.uni-karlsruhe.de>, kobylarz@wbkst21.mach.uni-karlsruhe.de wrote: > Robert Dewar wrote: > > How to alter the discriminant? I searched in several different sources of > documentation > and I have not found that. > > I declared variant record: > > type Tool_Operation(action : Action_Type := Wait) is > record > case action is > when Wait => howlong : time; > when Move => where : position; min_time : time; > end case; > end record; > > Let's define variable: > > top : Tool_Operation; > But such statement does not compile: > > top.action := Move; > > The compiler returns error: "left hand side of assignment must be a > variable" > > How to alter the discriminant? Whenever you change the discriminant of a variant record, you also have to change *all* the other fields (in the same assignment). That prevents you from getting "new" fields in your record with garbage values in them. This also prevents you from hosing the type of one of the fields by changing the variant so that its type changes out from under it. -- T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own