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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.172.129 with SMTP id l1mr12802734qaz.4.1373379150026; Tue, 09 Jul 2013 07:12:30 -0700 (PDT) X-Received: by 10.49.35.195 with SMTP id k3mr710792qej.2.1373379150012; Tue, 09 Jul 2013 07:12:30 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder02.blueworldhosting.com!news.ripco.com!news.glorb.com!t19no907200qam.0!news-out.google.com!f7ni1652qai.0!nntp.google.com!t19no907196qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 9 Jul 2013 07:12:29 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=129.59.203.98; posting-account=7Oy7OQoAAABhVYFOo553Cn1-AaU-bSfl NNTP-Posting-Host: 129.59.203.98 References: <0606a658-9816-4611-84dd-4f999bf6018e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Variant record limitation - what's a better solution? From: Eryndlia Mavourneen Injection-Date: Tue, 09 Jul 2013 14:12:30 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:16210 Date: 2013-07-09T07:12:29-07:00 List-Id: On Tuesday, July 9, 2013 1:38:09 AM UTC-5, Peter Brooks wrote: > Peter Brooks wrote: > > I'm still having trouble with this. I've tried using functions, as suggested, but it doesn't allow overloaded functions in the varient part. Here's what I tried: > > " > type > small_lorry_load is new integer range 1..2; > type > medium_lorry_load is new integer range 1..18; > type > large_lorry_load is new integer range 1..36; > type > all_lorry_loads is new integer range 1..36; > > type > lorry_size is (small,medium,large); > > type > lorry_type(lorry : lorry_size) is > record > number_plate : lorry_number_plate; > location : depot_name_type; > destination : depot_name_type; > case lorry is > when small => lorry_load : load(lorry); > when medium => lorry_load : load(lorry); > when large => lorry_load : load(lorry) > end case; > end record; > " > > I know that the syntax is wrong - I've been trying all sorts of alternatives. What have I not understood? As a point of instruction, the Lorry_Load types also could be defined like this: type All_Lorry_Loads is range 1..36; subtype Small_Lorry_Load is All_Lorry_Loads range 1..2; subtype Medium_Lorry_Load is All_Lorry_Loads range 1..18; subtype Large_Lorry_Load is All_Lorry_Loads range 1..36; which will make all the Lorry_Load types directly interrelated, thereby making the job of the programmer easier. The definition of All_Lorry_Loads also allows the compiler to choose the exact representation of the integers.