From: Eryndlia Mavourneen <eryndlia@gmail.com>
Subject: Re: Variant record limitation - what's a better solution?
Date: Tue, 9 Jul 2013 07:12:29 -0700 (PDT)
Date: 2013-07-09T07:12:29-07:00 [thread overview]
Message-ID: <e6d9fb37-3f15-4d66-8da6-de8fb3c514c3@googlegroups.com> (raw)
In-Reply-To: <krgb4h$qe8$3@news.albasani.net>
On Tuesday, July 9, 2013 1:38:09 AM UTC-5, Peter Brooks wrote:
> Peter Brooks <peter.h.m.brooks@gmail.com> 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.
prev parent reply other threads:[~2013-07-09 14:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 7:52 Variant record limitation - what's a better solution? Peter Brooks
2013-07-03 8:11 ` Georg Bauhaus
2013-07-03 9:39 ` Peter Brooks
2013-07-03 16:23 ` Jeffrey Carter
2013-07-03 18:35 ` Shark8
2013-07-03 19:26 ` Adam Beneschan
2013-07-09 11:48 ` Peter Brooks
2013-07-09 15:11 ` Adam Beneschan
2013-07-10 1:11 ` Peter Brooks
2013-07-03 20:55 ` Per Sandberg
2013-07-09 6:38 ` Peter Brooks
2013-07-09 7:49 ` Simon Wright
2013-07-09 8:22 ` Georg Bauhaus
2013-07-09 14:12 ` Eryndlia Mavourneen [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox