comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: Variant record limitation - what's a better solution?
Date: Wed, 03 Jul 2013 10:11:29 +0200
Date: 2013-07-03T10:11:27+02:00	[thread overview]
Message-ID: <51d3dcaf$0$6582$9b4e6d93@newsspool3.arcor-online.net> (raw)
In-Reply-To: <0606a658-9816-4611-84dd-4f999bf6018e@googlegroups.com>

On 03.07.13 09:52, Peter Brooks wrote:
> I see that I can't do what I'd like to with a variant record. What should I be doing?
>
> Here's an example:
>
> type
> my_object(X : size_type) is
>         record
>                name : string(1..80);
>                case X is
>                   when small => Y : small_type; -- line 20
>                   when medium => Y : medium_type; -- line 21
>                   when large => Y: large_type; -- line 22
>                end case;
>         end record;
>
> The errors are:
> line 21  'Y' conflicts with declaration at line 20
> line 22 'Y' conflicts with declaration at line 21
>
> I was hoping to have a different type depending on the case, but this doesn't seem allowed. What would achieve this?
>

Different types are o.K., the same name for different
components isn't. Three overloaded accessor functions Y
each returning one of the components will work.

  reply	other threads:[~2013-07-03  8:11 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 [this message]
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
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox