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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f0a123883ff0cb0f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.86.39 with SMTP id m7mr136052paz.4.1349748157077; Mon, 08 Oct 2012 19:02:37 -0700 (PDT) Received: by 10.68.212.99 with SMTP id nj3mr4846687pbc.20.1349748157062; Mon, 08 Oct 2012 19:02:37 -0700 (PDT) Path: t10ni23613332pbh.0!nntp.google.com!kt20no15647246pbb.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 8 Oct 2012 19:02:36 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <86a6f9d1-c99f-4184-aa79-ab7c15af9d4c@googlegroups.com> Subject: Re: API design considerations - variable-length array in record type From: Shark8 Injection-Date: Tue, 09 Oct 2012 02:02:37 +0000 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-10-08T19:02:36-07:00 List-Id: On Monday, October 8, 2012 3:03:04 AM UTC-6, Maciej Sobczak wrote: > > type R is record > X : Integer; > Y : Unbounded_String; > Z : Array_Of_Integers_That_We_Talk_About_Here; > end record; > > Requirements: > 1 - the enclosing record type should not be limited (it should be copyable) > 2 - the record type can be explicitly controlled, if necessary > 3 - the record type should be definite (it should not require initialization) > 4 - it should be possible to assign to Z, just as it is possible to assign to X and Y, and the new value for Z *might have a different length* Why not use discriminants on the record? Default : Constant := Natural'First; type R( Array_Length : Natural:= Natural'First ) is record X : Integer; Y : Unbounded_String; Z : Array_Of_Integers_That_We_Talk_About_Here(1..Array_Length):= (Others => Default); end record;