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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!eu.feeder.erje.net!news.internetdienste.de!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 03 Jul 2013 10:11:29 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Variant record limitation - what's a better solution? References: <0606a658-9816-4611-84dd-4f999bf6018e@googlegroups.com> In-Reply-To: <0606a658-9816-4611-84dd-4f999bf6018e@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <51d3dcaf$0$6582$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 03 Jul 2013 10:11:27 CEST NNTP-Posting-Host: cec1db89.newsspool3.arcor-online.net X-Trace: DXC=PKUl46aTE9g>jlK2>IgHGdMcF=Q^Z^V3h4Fo<]lROoRa8kFejVhA?6dnHRBSglEWc[;0Kf]3k X-Complaints-To: usenet-abuse@arcor.de Xref: news.eternal-september.org comp.lang.ada:16076 Date: 2013-07-03T10:11:27+02:00 List-Id: 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.