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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:ed07:: with SMTP id r7-v6mr4912046ith.27.1527442258528; Sun, 27 May 2018 10:30:58 -0700 (PDT) X-Received: by 2002:a9d:4712:: with SMTP id a18-v6mr887795otf.1.1527442258345; Sun, 27 May 2018 10:30:58 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder4.news.weretis.net!newsreader5.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!v8-v6no4409797itc.0!news-out.google.com!f20-v6ni4237itd.0!nntp.google.com!u74-v6no4381209itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 27 May 2018 10:30:58 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=80.139.101.198; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 80.139.101.198 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: Subject: Re: why "unconstrained subtype in component declaration" while said component given default value ? From: AdaMagica Injection-Date: Sun, 27 May 2018 17:30:58 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 3424 X-Received-Body-CRC: 3815093358 Xref: reader02.eternal-september.org comp.lang.ada:52735 Date: 2018-05-27T10:30:58-07:00 List-Id: 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.