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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!pyrnj!mirror!gabriel!ada-uts!stt From: stt@ada-uts Newsgroups: comp.lang.ada Subject: Re: variant records Message-ID: <4700082@ada-uts> Date: Thu, 6-Nov-86 10:40:00 EST Article-I.D.: ada-uts.4700082 Posted: Thu Nov 6 10:40:00 1986 Date-Received: Mon, 10-Nov-86 22:05:40 EST References: <2886@rsch.WISC.EDU> Nf-ID: #R:rsch.WISC.EDU:-288600:ada-uts:4700082:000:1108 Nf-From: ada-uts!stt Nov 6 10:40:00 1986 List-Id: You have fallen into a couple of Ada traps. First, all objects created by an allocator are constrained, even if the type has defaults (see LRM 4.8:5 "If the type of the created object is an array type or a type with discriminants, the the created object is always constrained.") Hence, by saying simply "new node" you have created an object with the default discriminant, and constrained to stay that way. Secondly, by having a record component whose discriminant depends on the discriminant of the enclosing record, the component is constrained by the enclosing discriminant, and the enclosing discriminant cannot be changed by assigning to just the component. To solve your problem, you should either remove the discriminant from the outer record type "node" and declare the xrec component without a discriminant (hence unconstrained), or maintain separate node free lists for each distinct discriminant value, and allocate using "new node(discrim)" where discrim is the discriminant of the component rec being pushed (this will require that you pass discrim as a parameter to your "new_node" function).