From: Shark8 <onewingedshark@gmail.com>
Subject: Re: API design considerations - variable-length array in record type
Date: Mon, 8 Oct 2012 19:02:36 -0700 (PDT)
Date: 2012-10-08T19:02:36-07:00 [thread overview]
Message-ID: <86a6f9d1-c99f-4184-aa79-ab7c15af9d4c@googlegroups.com> (raw)
In-Reply-To: <c40023e6-e7d1-431f-8759-5ac224c0aa1f@googlegroups.com>
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;
next prev parent reply other threads:[~2012-10-09 2:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-08 9:03 API design considerations - variable-length array in record type Maciej Sobczak
2012-10-08 11:13 ` Simon Wright
2012-10-08 11:29 ` Egil Høvik
2012-10-08 11:53 ` Maciej Sobczak
2012-10-08 14:37 ` Tero Koskinen
2012-10-09 2:02 ` Shark8 [this message]
2012-10-09 5:16 ` Adam Beneschan
2012-10-09 5:45 ` Shark8
2012-10-09 5:42 ` Niklas Holsti
2012-10-09 3:10 ` Stephen Leake
2012-10-09 7:47 ` Maciej Sobczak
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox