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-Received: by 2002:a6b:338f:: with SMTP id z137-v6mr2615768ioz.130.1527445055962; Sun, 27 May 2018 11:17:35 -0700 (PDT) X-Received: by 2002:a9d:5543:: with SMTP id h3-v6mr874775oti.13.1527445055738; Sun, 27 May 2018 11:17:35 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!u74-v6no4418620itb.0!news-out.google.com!f20-v6ni4237itd.0!nntp.google.com!u74-v6no4418615itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 27 May 2018 11:17:35 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.113.16.86; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 76.113.16.86 References: <2d717805-f6a4-4de9-bf4a-d45037034f96@googlegroups.com> <9b76440e-ab22-4fcf-8a54-f85a9d4d010a@googlegroups.com> <067fdb8b-e69c-4ec7-b7ae-50a11dc97d83@googlegroups.com> <71948f43-cf43-448f-a7b0-0e5982c98d90@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1e6ddc66-cb54-4023-8546-a1c0898c25d9@googlegroups.com> Subject: Re: why "unconstrained subtype in component declaration" while said component given default value ? From: Shark8 Injection-Date: Sun, 27 May 2018 18:17:35 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:52740 Date: 2018-05-27T11:17:35-07:00 List-Id: 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.