comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: why "unconstrained subtype in component declaration" while said component given default value ?
Date: Sun, 27 May 2018 11:17:35 -0700 (PDT)
Date: 2018-05-27T11:17:35-07:00	[thread overview]
Message-ID: <1e6ddc66-cb54-4023-8546-a1c0898c25d9@googlegroups.com> (raw)
In-Reply-To: <c187db83-d37f-41d9-9728-6383f8c03713@googlegroups.com>

On Sunday, May 27, 2018 at 11:30:59 AM UTC-6, AdaMagica wrote:
> Am Sonntag, 27. Mai 2018 19:15:01 UTC+2 schrieb Shark8:
> > On Saturday, May 26, 2018 at 6:29:11 PM UTC-6, Mehdi Saada wrote:
> > > > Record types need to support Representation Clauses, where as normal 
> > > > variables do not.
> > > That's quite an argument. But still...
> > > >    type A (N: Positive) is record
> > > >       II : Integer;
> > > >       Chaine : String(1..N) := Give_String(N);
> > > >    end record;
> > > how can one define bit by bit the representation of A since N is not statically defined?
> > 
> > It's not hard; in fact it's the standard way to deal with something like SSL's message-format. I don't remember the details of the actual records, but here's the concept:
> > 
> > Message Fields: Type, Length, Encryption, Text.
> > 
> > With Encryption;
> > Package Message is
> >   Type Message_Type is ( Internal, External, Loop, Heartbeat )
> >     with Size => 2; -- Whatever.
> >   
> >   Type Message( <> ) is private;
> >   -- Operations.
> > Private
> >     Package Enc renames Encryption;
> >     Type Message( Length : Positive; Style : Message_Type ) is record
> >      Text       : String(1..Length);
> >      Encryption : Enc.Method; -- Encryption method; say 6 bits.
> >     End record;
> >     
> >    For Message use record
> >     Style      at 0 range 0..2;
> >     Encryption at 0 range 3..8;
> >     Length     at 0 range 9..40;
> >    End Record;
> > End Message;
> > 
> > Or something like that; like I said, that's the general idea, not the specifics.
> > To read up on record representation clauses read this:
> > http://archive.adaic.com/standards/83lrm/html/lrm-13-04.html
> 
> No, that doesn't work for a discriminated record like this. Rep clauses must be static. So you can only give rep specs for the static components; just omit the nonstatic one. The compiler will allocate it as the last one.

The representation clause *IS* static. Notice the location for Text is not given, just as you are saying.

  reply	other threads:[~2018-05-27 18:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 21:03 why "unconstrained subtype in component declaration" while said component given default value ? Mehdi Saada
2018-05-26 21:40 ` Jere
2018-05-26 22:11   ` Mehdi Saada
2018-05-26 23:55     ` Jere
2018-05-27  0:14       ` Jere
2018-05-27  0:29       ` Mehdi Saada
2018-05-27  0:45         ` Mehdi Saada
2018-05-27 17:15         ` Shark8
2018-05-27 17:30           ` AdaMagica
2018-05-27 18:17             ` Shark8 [this message]
2018-05-29  1:28               ` AdaMagica
2018-05-29 17:20                 ` Mehdi Saada
2018-05-27  7:45   ` Jeffrey R. Carter
2018-05-26 23:41 ` Shark8
2018-05-27  7:07 ` Simon Wright
2018-05-27 17:22   ` Shark8
2018-05-27 12:24 ` Mehdi Saada
2018-05-29 22:28   ` Randy Brukardt
replies disabled

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