* Representation clause of a discriminated record
@ 2016-08-03 5:04 David SAUVAGE
2016-08-03 6:13 ` Jeffrey R. Carter
0 siblings, 1 reply; 6+ messages in thread
From: David SAUVAGE @ 2016-08-03 5:04 UTC (permalink / raw)
Hi.all,
For a data frame which length can vary, we have described this data frame as a record, and wish to describe it's representation clause.
What would be a valid representation clause for the following discriminated record ? (taken from the Ada wikibook [1])
type Discriminated_Record (Size : Natural) is
record
A : String (1 .. Size);
end record;
[1] https://en.wikibooks.org/wiki/Ada_Programming/Types/record#Discriminated_record
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Representation clause of a discriminated record
2016-08-03 5:04 Representation clause of a discriminated record David SAUVAGE
@ 2016-08-03 6:13 ` Jeffrey R. Carter
2016-08-03 15:22 ` Per Sandberg
0 siblings, 1 reply; 6+ messages in thread
From: Jeffrey R. Carter @ 2016-08-03 6:13 UTC (permalink / raw)
On 08/02/2016 10:04 PM, David SAUVAGE wrote:
>
> What would be a valid representation clause for the following discriminated record ? (taken from the Ada wikibook [1])
>
> type Discriminated_Record (Size : Natural) is
> record
> A : String (1 .. Size);
> end record;
for Discriminated_Record use record
Size at 0 range 0 .. 31;
end record;
if Integer'Size = 32. You can't give a representation for A because you don't
know it's size.
--
Jeff Carter
"Mr. President, we must not allow a mine-shaft gap!"
Dr. Strangelove
33
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Representation clause of a discriminated record
2016-08-03 6:13 ` Jeffrey R. Carter
@ 2016-08-03 15:22 ` Per Sandberg
2016-08-03 16:43 ` david.sauvage
2016-08-03 16:46 ` David SAUVAGE
0 siblings, 2 replies; 6+ messages in thread
From: Per Sandberg @ 2016-08-03 15:22 UTC (permalink / raw)
Well
I would add a Aspect/Pragma "pack" as well, since some architectures
may insert padding to start objects on boundaries /= 32 bit.
type Discriminated_Record (Size : Natural) is
record
A : String (1 .. Size);
end record with Pack => True;
for Discriminated_Record use record
Size at 0 range 0 .. 31;
end record;
/Per
Den 2016-08-03 kl. 08:13, skrev Jeffrey R. Carter:
> On 08/02/2016 10:04 PM, David SAUVAGE wrote:
>>
>> What would be a valid representation clause for the following discriminated record ? (taken from the Ada wikibook [1])
>>
>> type Discriminated_Record (Size : Natural) is
>> record
>> A : String (1 .. Size);
>> end record;
>
> for Discriminated_Record use record
> Size at 0 range 0 .. 31;
> end record;
>
> if Integer'Size = 32. You can't give a representation for A because you don't
> know it's size.
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Representation clause of a discriminated record
2016-08-03 15:22 ` Per Sandberg
@ 2016-08-03 16:43 ` david.sauvage
2016-08-03 16:46 ` David SAUVAGE
1 sibling, 0 replies; 6+ messages in thread
From: david.sauvage @ 2016-08-03 16:43 UTC (permalink / raw)
>On Wednesday, August 3, 2016 at 7:23:02 PM UTC+4, Per Sandberg wrote:
>> Den 2016-08-03 kl. 08:13, skrev Jeffrey R. Carter:
Thanks all for your feedbacks, my wish is about adding A in the representation clause
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Representation clause of a discriminated record
2016-08-03 15:22 ` Per Sandberg
2016-08-03 16:43 ` david.sauvage
@ 2016-08-03 16:46 ` David SAUVAGE
2016-08-04 21:23 ` Randy Brukardt
1 sibling, 1 reply; 6+ messages in thread
From: David SAUVAGE @ 2016-08-03 16:46 UTC (permalink / raw)
>On Wednesday, August 3, 2016 at 7:23:02 PM UTC+4, Per Sandberg wrote:
>> Den 2016-08-03 kl. 08:13, skrev Jeffrey R. Carter:
Thanks all for your feedbacks, my wish is about adding A in the representation clause
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Representation clause of a discriminated record
2016-08-03 16:46 ` David SAUVAGE
@ 2016-08-04 21:23 ` Randy Brukardt
0 siblings, 0 replies; 6+ messages in thread
From: Randy Brukardt @ 2016-08-04 21:23 UTC (permalink / raw)
"David SAUVAGE" <david.sauvage@adalabs.com> wrote in message
news:c3625d1a-62a5-4507-9c37-1baa81c74f61@googlegroups.com...
> >On Wednesday, August 3, 2016 at 7:23:02 PM UTC+4, Per Sandberg wrote:
>>> Den 2016-08-03 kl. 08:13, skrev Jeffrey R. Carter:
>
>
> Thanks all for your feedbacks, my wish is about adding A in the
> representation clause
You can't do that, the size of items in representation clauses have to be
static (that is, known at compile-time). It doesn't make sense to specify
the location of something of unknown properties.
Note that by giving all of the other components, you effectively place the A
component in a particular location (the one left over). But I'd suggest
using some sort of static data structure.
Randy.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-08-04 21:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-03 5:04 Representation clause of a discriminated record David SAUVAGE
2016-08-03 6:13 ` Jeffrey R. Carter
2016-08-03 15:22 ` Per Sandberg
2016-08-03 16:43 ` david.sauvage
2016-08-03 16:46 ` David SAUVAGE
2016-08-04 21:23 ` Randy Brukardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox